First of all, let us say the background: Recently in a project, the development of a micro-letter function, the use of ASP.net development, jquery1.8.0 version.
Click on the button to trigger the event in the micro-letter, invoke Ajax to interact with the server side, the callback function is error.
The reason: The first thing I thought of was the data type that was returned was problematic because in the jquery version more than 1.4 The JSON format was very strict and needed to conform to the format of {"Target": true, "message": "Success"}. The response object is analyzed with json.stringify () function, and the result is consistent and the reason is excluded.
Since Ajax is taking the error, I began to analyze the parameters of the error function, respectively, XMLHttpRequest, Textstatus, Errorthrown. I found that xmlhttprequest.status equals 0,xmlhttprequest.readystate equals 0, stating that there are XMLHttpRequest objects in the form that are not initialized, and then begin to study how to initialize XMLHttpRequest objects.
Solution:
var XMLHttpRequest;
$ (function () {
if window. XMLHttpRequest) {
xmlhttprequest=new XMLHttpRequest ();
} else{
xmlhttprequest=new ActiveXObject ("Microsoft.XMLHTTP");
}
Xmlhttprequest.open ("Get", "Ajaxservlet", true);
This will solve the problem described above, note that PC-side access to general Ajax does not cause problems, because the browser in the PC has a built-in XMLHttpRequest object, and in the micro-letter, this phenomenon may need to manually build and initialize.
PS: Android micro-letter with browser and IE6 browser AJAX request abort error handling
A click event is bound to the page element to trigger an AJAX request, and in an Choweixin browser and IE6, the request is often interrupted, returning the error type "Abort", which is normal in all other browsers.
Using FIDDLER2 and HttpWatch monitoring requests in IE6, "aborted" is often present, and tossing a weekend, ...
Don't talk nonsense ....
Workaround: Add onclick= ' return false on the label