During the Ext.ajax.request:ajax call, never overwrite the request.

Source: Internet
Author: User
Tags object

The mistake of a day's adjustment today, very depressed, until the evening found that the original page is defined in the XMLHttpRequest object is a global object, but there are two Ajax calls to it, every few minutes there will be problems, or inexplicable problems, I think there is a problem of data parsing or background problems, Tune, the result is two Ajax calls, the second call the same request, that is, covering the first, the first time to get a second value, resulting in parsing error ....
Each subsequent Ajax call must not save the request with a global variable. Instead, it is generated temporarily and then binds the request to its processing.
function Test () {
var temp_request = Createxmlhttprequest ();
Deal_change.request = Temp_request;
Temp_request.onreadystatechange=deal_change;
Temp_request.open ("Get", url,true);
Temp_request.setrequestheader ("If-modified-since", "0"); Do not cache Ajax
Temp_request.send (NULL);
}
function Deal_change ()
{
var rstr;
try{
if (deal_change.request.readystate==4) \
Calling its request through a deal_change.request reference
{
if (deal_change.request.status==200)
{
RSTR = Trim (deal_change.request.responseText);
...................
}}}
Remember to remember.
Of course, if you use the framework, you don't have to bother. This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20120721/32053.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.