我建立我自己的小部件道场如这里讨论:Custom Widget后JSON数据
现在,我想用下面的代码张贴在特定事件中的数据:
xhr.post({
handleAs: "json",
form: "answerForm",
timeout: 15000,
load: lang.hitch(this, "_onSubmitted", button),
error: lang.hitch(this, "_onSubmitError", button)
});
我希望这样的事情在我xhr.post content: dojo.toJson(this)
我怎么能发送JSON格式的数据到服务器? 谢谢!
编辑:加入HTML模板
<form id="answerForm" action="${url}">
<div data-dojo-attach-point="selectionAnswerWidget" data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'bottom'">
<div data-dojo-type="dojo.store.Memory" data-dojo-id="answerStore"
data-dojo-props="data: [{id: 'YES', name: 'yes'}, {id: 'NO', name: 'no'}, {id: 'UNANSWERED', name: 'unanswered'}]"></div>
<input data-dojo-type="dijit.form.FilteringSelect" value="${answer}"
data-dojo-props="store:answerStore, searchAttr:'name'" data-dojo-attach-point="answerSelection" />
</div>
<div data-dojo-attach-point="textAreaAnswerWidget" data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'top'">
<textarea data-dojo-attach-point="commentNode" rows="5" cols="50" data-dojo-type="dijit.form.SimpleTextarea"
data-dojo-props="selectOnClick:true">${comment}</textarea>
</div>
的数据是正确的HTML和后到达服务器,但没有数据。
我纠正了我的'data-dojo-attach-point' – myborobudur 2012-04-03 07:02:25