Tao elder brother Strength, is a horse, unfortunately the parallel to the boss.
Failure occurs after a complete abandonment. I was very disappointed with my boss.
The company has recently completed a project, the project has come to an end, has not been a return to the empty filter. In the elder brother proposed, the boss research for half a day can not solve, finally threw to Tao brother solution. Although it is everyone's duty to solve the problem, it is not everyone's responsibility. But brother Tao still hold the attitude of learning, solve the problem. Finally resolved. Directly on the back of the code:
Ext.override (Ext.ajax, {request:function (options) {options = Options | |
{}; if (Options.url&&options.url.indexof (' login.jsp ') >-1) {location.href= ' Http://download.csdn.net/detail
/xmt1139057136/7113051 ';
Return var me = this, scope = Options.scope | | window, username = Options.username | | Me.username, password = Options.password | | Me.password | |
", async, Requestoptions, request, headers, XHR;
if (me.fireevent (' beforerequest ', Me, Options)!== false) {requestoptions = me.setoptions (options, scope);
if (Me.isformupload (options)) {me.upload (Options.form, Requestoptions.url, Requestoptions.data, Options);
return null;
} if (Options.autoabort | | me.autoabort) {me.abort (); } async = Options.async!== false?
(Options.async | | me.async): false;
XHR = me.openrequest (options, requestoptions, async, username, password); headers = me.setupheaders (XHR, Options, Requestoptions.data, Requestoptions.paraMS); Request = {ID: ++ext.data.connection.requestid, XHR:XHR, Headers:headers, options:options, async:
Async, Timeout:settimeout (function () {request.timedout = true;
Me.abort (Request); }, Options.timeout | |
Me.timeout)};
Me.requests[request.id] = Request;
Me.latestid = request.id;
if (async) {Xhr.onreadystatechange = Ext.Function.bind (Me.onstatechange, ME, [request]);
} xhr.send (Requestoptions.data);
if (!async) {return me.oncomplete (request);
return request;
else {ext.callback (options.callback, Options.scope, [options, Undefined, undefined]);
return null; }
}
});
Here, if your Ajax request accesses a login.jsp page, jump to the CSDN page.
Here, add the Beforerequest event before all AJAX requests are posted.
Ext.Ajax.addListener ("Beforerequest", Function (conn, options, eopts) {
if (options) {
if (options.url& &options.url.indexof (' Userreport-getdevicereport ') >-1) {
location.href= ' http://download.csdn.net/ detail/xmt1139057136/7112943 ';
return;}}
, this
);
There are a lot of good ways, I use the Requestcomplete event here, the background using the filter, if found to be null NULL, I will modify the response
Response.setcontenttype ("Text/html;charset=utf-8;iflogin=error");
Then in the return of the results to judge, there are content-type exist Iflogin=error, jump to the background of the login page.
Ext.Ajax.addListener ("Requestcomplete", function (conn, response, options, eopts) {
var msg = Response.getallresponseheaders ();
if (msg[' Content-type '].indexof (' iflogin=error ')!=-1) {
window.location.href=serverpath+ ' admin/login.jsp ';
}
},this);
Well, that's the end of it. You are welcome to pay attention to my personal blog.