查看Ext.data.JsonP源码重写了源码中的方法,以便能够加入自动提示。看起来不是那么的优雅,求高人指点
1 var me = this; 2 //提示消息 3 me.message = '正在努力加载中...'; 4 //提示消息组件 5 var cardPanel = Ext.getCmp('cardPanel'); 6 Ext.data.JsonP.handleResponse = function (result, request) { 7 var success = true; 8 9 if (request.timeout) { 10 clearTimeout(request.timeout); 11 } 12 13 delete this[request.callbackName]; 14 delete this.requests[request.id]; 15 16 this.cleanupErrorHandling(request); 17 Ext.fly(request.script).destroy(); 18 19 if (request.errorType) { 20 success = false; 21 Ext.callback(request.failure, request.scope, [request.errorType, request]); 22 } else { 23 Ext.callback(request.success, request.scope, [result, request]); 24 } 25 Ext.callback(request.callback, request.scope, [success, result, request.errorType, request]); 26 //隐藏消息提示 27 cardPanel.hideMessage(); 28 }; 29 30 Ext.data.JsonP.createScript = function (url, params, options) { 31 //显示消息提示 32 if (me.message) { 33 cardPanel.showMessage(me.message, true); 34 } 35 var script = document.createElement('script'); 36 script.setAttribute("src", Ext.urlAppend(url, Ext.Object.toQueryString(params))); 37 script.setAttribute("async", true); 38 script.setAttribute("type", "text/javascript"); 39 return script; 40 };