我目前正按以下方式发送回调
var submitCommunicateCard = function () {
//display Loading indicator to user
console.log(rpc.views.Contact.CommunicateCard.getValues());
Ext.Ajax.request({
url: WebService('GetInTouch', 'CommunicateCard'),
method: 'post',
params: {
callback: 'foo', // THIS SUCKS!!!
name: 'Test Name'
}
});
};
虽然这样可行,但我更愿意让Sencha为我添加回调。
我尝试了这个,咬了无效
var submitCommunicateCard = function () {
//display Loading indicator to user
console.log(rpc.views.Contact.CommunicateCard.getValues());
Ext.Ajax.request({
url: WebService('GetInTouch', 'CommunicateCard'),
method: 'post',
scriptTag: true, //WHY DOESN'T THIS WORK?
params: {
name: 'Test Name'
}
});
};
如何正确地向Sencha Touch Ext.Ajax.request()添加“回调”?
答案 0 :(得分:0)
Ext.Ajax生成两种类型的请求后事件,即requestcomplete和requestexception。您可以Ext.Ajax.on("requestcomplete", function (conn, response, options))
用于成功请求,Ext.Ajax.on("requestexception", function (conn, response, options))
用于失败请求。
答案 1 :(得分:0)
答案是“你不能”
您必须使用Ext.util.JSONP.request();