[ExtJS]常用一般function

  • Ajax範例
    //啟動時遮照
    Ext.Ajax.on('beforerequest', function () {
        Ext.getBody().mask("Loading");
    }, this);
    //結束時移除遮照
    Ext.Ajax.on('requestcomplete', function () {
        Ext.getBody().unmask();
    }, this);
    var paramObj = new Object();
    paramObj.id = "123";
    //Ext.getBody().mask("Loading2");
    Ext.Ajax.request({
        url: "MyAjax.jsp",
        scope: this,
        method: "post",
        success: function (
        response) {
            Ext.getBody()
                .unmask();
            var json = Ext.decode(response.responseText);
            //{success:false|true,msg:'訊息'}
            if (json.success) {
                //回傳success要做的事
            } else {
                //錯誤時alert
                alert(json.msg);
    
            }
    
        }, // .createDelegate(this),
        failure: function () {
            if (action.response.status == 200) {
    
                var json = Ext.decode(action.response.responseText);
                Ext.MessageBox.alert(json.msg);
            } else Ext.MessageBox.alert("Save Error~");
        },
    
        params: paramObj
    });
    
    

發表迴響