這裏是我的源代碼:道場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