如果slave ajax请求在extjs中失败,如何停止master ajax请求

时间:2014-08-18 13:54:24

标签: java javascript ajax extjs

我是extjs 4.1的新手,我开发了一个小应用程序,其中我有一个主从概念,即基于主人的ajax成功我必须解雇奴隶的ajax请求,如果奴隶失败然后掌握也应该失败,反之亦然。请找到我的代码的以下片段

Controller.js

    Ext.define('Basel3.controller.Contacts', {
        extend: 'Ext.app.Controller',
        stores:['...My all store goes here...'],
        models:['...My all models goes here...'],
        views: ['...My all views goes here...'],
        refs:[{
            My all references goes here
        }],
        init: function(){
              this.control({
                ....
        })
        },
        save: function() {
              this.getRulesStore().save();
              this.getRuleDetailsStore().save();
        }
    }

与前面提到的代码一样,我们可以看到我已经使用商店将数据保存在我的数据库中,这会激发单独的ajax请求,这是我不想做的。以下是各实体的商店和型号。

模型

规则明细:

      Ext.define('Basel3.model.RuleDetail', {
         extend: 'Ext.data.Model',
         fields: [{name: 'ruleDetailId', type: 'int'},
         {name: 'ruleId',type: 'string'},
         {name: 'attrName',type: 'string'},
         {name: 'attrType',type: 'string'},
         {name: 'attrOprtr',type: 'string'},
         {name: 'attrValue',type: 'string'}
        ]
      });

规则:

    Ext.define('Basel3.model.Rule', {
        extend: 'Ext.data.Model',
        fields: [{name: 'ruleName',type: 'string'},
         {name: 'ruleGroup', type: 'string'},
         {name: 'ruleReportName', type: 'string'},
         {name: 'ruleCategory',type: 'string'},
         {name: 'ruleTypeId',type: 'string'},
         {name: 'ruleFactor',type: 'string'},
         {name: 'effDate',type: 'date', dateFormat :'d-M-y'}
        ]
    });

商户:

规则明细:

    Ext.define('Basel3.store.Contacts', {
      extend: 'Ext.data.Store',
      model: 'Basel3.model.Contact',
      autoLoad: true,
      pageSize: 35,
      storeId : 'Contacts',
      autoLoad: {start: 0, limit: 35},
      sorters: ['attrType'],
      groupField: 'attrType',            
      proxy: {
           type: 'ajax',                
      api: {
        read : 'ruledetail/view.action',
        create : 'ruledetail/create.action',
        update: 'ruledetail/update.action',
        destroy: ''
      },
      model : 'Basel3.model.Contact',

      reader: {                 //reads the data in the JSON Format
        type: 'json',
        root: 'data',
        successProperty: 'success'
      },

      writer: {
        type: 'json',           //writes the data in the JSON Format
        writeAllFields: true,
        encode: true,
        root: 'data'
      },

      listeners: {              //Exception Handler for the Ajax Request
        exception: function(proxy, response, operation){
            var error = Ext.decode(response.responseText);
            Ext.MessageBox.show({
                title: 'RULE DETAILS REMOTE EXCEPTION',
                msg: error.message,
                icon: Ext.MessageBox.ERROR,
                buttons: Ext.Msg.OK
            });
        }
    }
}
    });

规则:

    Ext.define('IntellectB3.store.Rule', {
        extend: 'Ext.data.Store',
        model: 'IntellectB3.model.Rule',
        storeId : 'Rule',
        autoLoad: true,
        pageSize: 35,
        autoSync : true,
        autoLoad: {start: 0, limit: 35},
        proxy: {
           type: 'ajax',                
        api: {
           read : 'rule/view.action',
           create : 'rule/create.action',
           update: 'rule/update.action',
           destroy: ''
        },

       reader: {                    
           type: 'json',
           root: 'data',
           successProperty: 'success'
       },

      writer: {
         type: 'json',          //writes the data in the JSON Format
         writeAllFields: true,
         encode: true,
         root: 'data'
      },

      listeners: {              //Exception Handler for the Ajax Request
        exception: function(proxy, response, operation){

            var error = Ext.decode(response.responseText);
            Ext.MessageBox.show({
                title: 'RULE MASTER REMOTE EXCEPTION',
                msg: error.message,
                icon: Ext.MessageBox.ERROR,
                buttons: Ext.Msg.OK

            });
        }
    }
}
    });

提前致谢,等待谦虚的回复

0 个答案:

没有答案