这里是我的源代码:道场xhrPost问题
<script>
function sendText(){
require([ "dijit/form/Button", "dojo/_base/xhr"],
function(Button,xhr) {
xhr.post({
url: "validURL1.html",
form: dojo.byId("myForm"),
load: function(data){
var newStore =
new ItemFileWriteStore({url:'validURL2.html'});
dijit.byId("grid").setStore(newStore);
},
error: function(error){
alert("error!");
}
});
});
}
</script>
<button data-dojo-type='dijit.form.Button' onClick ='sendText()'>submit</button>
但是,当我按下按钮,并尝试将我的数据发布到服务器,萤火说:
_145未定义
那么我的代码有什么问题? 什么是'_145'错误?
UPDATE
<script>
require([ "dijit/form/Button", "dojo/_base/xhr","dijit/form/Form", "dojo/data/ItemFileWriteStore",
"dojo/dom-form","dijit/registry","dojo/ready", "dojox/grid/EnhancedGrid"],
function(Button,xhr, Form, ItemFileWriteStore, domForm, registry,ready, EnhancedGrid) {
var hasBeenSent = false;
window.sendText = function() {
xhr.post({
url: "validURL1.html",
form: dojo.byId("myForm"),
handleaAs: "text",
load: function(data) {
var newStore = new ItemFileWriteStore({url:'validURL2.html'});
dojo.byId("grid").setStore(newStore);
},
error: function(error){
alert("error!");
},
handle: function() {
hasBeenSent = true;
}
});
}
});
</script>
现在它说:
TypeError: dojo.byId("grid").setStore is not a function
不过,我需要 “enhancedGrid”。所以也许我应该需要一些其他模块或类?
IM不能完全肯定,但我认为,如果您设置了'load'和'handle',那么只有一个会跑 – mschr