我使用
store.sync({
success:function(){},
failure:function(){}
});
与服务器同步;当服务器返回 {success:false} 或 {success:true} 时;
我如何从 store.sync 中的服务器检查 json。
我知道:success 被调用 成功完成同步后要调用的函数,即使返回 {sucess :false} ,不仅 {success:true};
最佳答案
您需要在商店的代理中将读者的 successProperty 更改为 false。
store.proxy.reader.successProperty = false;
或者
var store = Ext.create('Ext.data.Store', {
(...)
proxy : {
type : 'ajax',
(...)
reader : {
successProperty : false,
(...)
}
}
});
然后你可以使用这个:
store.sync({
callback : function (batch, options) {
var operations = batch.operations;
for (var x in operations) {
var operation = operations[x];
if (operation.request) {
console.log('operation.request ---> ', operation.request);
}
if (operation.response) {
console.log('operation.response ---> ', operation.response);
var object = Ext.decode(operation.response.responseText, false);
console.log('success --->', object.success);
}
}
}
});
关于extjs - 如何在 Extjs 中检查商店同步的返回状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18734259/