我建立我自己的小部件道場如這裏討論: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