extjs - 如何在 Extjs 中检查商店同步的返回状态

标签 extjs

我使用

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/

相关文章:

extjs - 使用 EXTJS 覆盖面板/网格中的展开/折叠动画

android - Sencha Touch 2 - Android 打包错误

extjs - 在中心垂直对齐项目-Sencha Panel

extjs - 使用 Sencha Touch Windows Phone 应用程序 + Windows Azure 移动服务 + 自定义后端推送通知

javascript - EXTJS 5 : How to have the checkbox selected only when clicking on checkbox in grid

javascript - 使用 extjs 时在数据中保留空白

java - 使用 Jersey 和 ExtJS 使用 JSON 的 Rest Web 服务

asp.net - Ajax 数据更新。扩展程序

javascript - 如何在这段代码中不使用 Ext.getCmp 来执行相同的操作?

javascript - 如何在加载时根据条件隐藏 Ext 菜单中的项目