I have never noticed this before. Thanks to my reading of the kuibono article today, the following is the code snippet provided by kuibono to manually recycle the xmlHttpRequest object:
Each jquery Ajax request creates an xmlHttprequest object. Theoretically, a persistent connection request is an infinite recursion and the number of requests is very large. However, each request creates a new xmlhttprequest, in addition, jquery does not automatically Recycle resources, resulting in memory overflow.
By viewing the jquery API, it is found that jquery also has a complete object, which is a callback function after the request is complete (called after the request is successful or fails ). There are also two parameters: XMLHttpRequest and textStatus. Therefore, you only need to manually recycle the returned XMLHttprequest object after the request is complete. The Code is as follows:
Copy codeThe Code is as follows:
$. Ajax ({
Url: "http://www.jb51.net ",
Data: {name: "xxxx "},
DataType: "xml ",
Success: function (data, textStatus ){
// Do something...
},
Complete: function (XHR, TS) {XHR = null}
});