IE send Ajax request to return the previous result solution _ajax related

Source: Internet
Author: User
Problem occurs because:

1. IE will only create an AJAX request below, the response results in the browser cache in the next call to the AJAX request from the cache read

Get mode, obtain data, because the sending parameters and address are consistent, so IE browser will be taken from the cache, but not to request the server side, and the post method because of the different parameters, will not produce this problem

2. Firefox will re-establish an AJAX request every time the event is activated

Workaround:

1: After the Ajax requested page, add a random function, we can use the random time function

Add T=math.random () after the URL sent by javascript

For example: url+ "&" + "t=" +math.random (); or new Date (); After the URL parameter, add "? timestamp=" + New Date (). GetTime ();

2.
Copy Code code as follows:

$.ajax ({

Type: "POST",

Async:false,//Set sync mode

cache:false,//Cache

Url:url,

Data:data,

Success:function (data) {
Operation after successful return of value

}

});

The solution is cache:false.

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.