1
我尝试使用dojox.data.JsonRestStore和我的RESTful服务。我通过sitepen和dojox文档阅读文章,但我无法理解它们的含义。 我的服务变得像http://<host>/rest/relatedsuggestion?query=weath&results=3
请求并返回JSON如何在我的RESTful服务中使用JsonRestStore
{
Suggestions: [
“weather channel”,
“weather forecast”,
“weather bbc”
]
}
这意味着它无法理解像http://<host>/rest/relatedsuggestion/3
这是在每一个教程中使用的要求。我怎样才能让它理解我的格式?据我所知,这个课程的答案也是不寻常的。
为了尽量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>
嗨基里尔,纠正我,如果我错了,我认为这是一个异步。所以poStore.fetchItemByIdentity代码应该在dojox.data.JsonRestStore的onComlete方法中。 – rajkamal 2011-06-15 06:58:34
我不知道,但文档中没有这样的事件(有onDelete,onNew,onSet) – 2011-06-15 08:51:40