作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试将 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/
我是一名优秀的程序员,十分优秀!