gpt4 book ai didi

javascript - 如何将 JsonRestStore 与我的 RESTful 服务结合使用

转载 作者:行者123 更新时间:2023-11-28 10:17:05 26 4
gpt4 key购买 nike

我尝试将 dojox.data.JsonRestStore 与我的 RESTful 服务一起使用。我阅读了 sitepen 和 dojox 文档的文章,但我无法理解它们的全部内容。我的服务收到类似 http://<host>/rest/relatedsuggestion?query=weath&results=3 的请求并返回 JSON

{
Suggestions: [
“weather channel”,
“weather forecast”,
“weather bbc”
]
}

这意味着它无法理解像 http://<host>/rest/relatedsuggestion/3 这样的请求每个教程中都会使用它们。我怎样才能让它理解我的格式?据我了解,这个类(class)的 react 也很不寻常。

为了尝试 JsonRestStore,我编写了以下模拟页面,当然它不起作用并返回 4 个错误“类型错误:_57 为空”:

<head>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojox.data.JsonRestStore");
dojo.require("dojox.grid.DataGrid");

dojo.addOnLoad(function() {
var poStore = new dojox.data.JsonRestStore({target:"http://<host>/rest/features/relatedsuggestion"});

poStore.fetchItemByIdentity({
identity:"3433",
onItem:function(poItem){
poItem.completeOrder();
}
});
});
</script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
/>
</head>

<body class=" claro ">
<div id="gridElement"></div>
</body>

最佳答案

这篇 IBM DeveloperWorks 文章可能会有所帮助:Use Dojo's JsonRestStore with your REST services .

根据您的描述,您的服务是非标准的,因此您需要调整 URL 和响应调整以符合 JsonRestStore 的预期。该文章解释了如何通过实现自己的服务来做到这一点。

关于javascript - 如何将 JsonRestStore 与我的 RESTful 服务结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6344101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com