Ajax caching problem under IE8 and its solution _ajax related

Source: Internet
Author: User
Tags json

Introduction to Ajax

Ajax, "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), refers to a web development technology that creates interactive Web applications.

AJAX = Asynchronous JavaScript and XML (a subset of standard generic markup languages).

AJAX is a technique for creating fast-moving web pages.

AJAX enables asynchronous updating of Web pages by making a small amount of data exchange in the background with the server. This means you can update portions of a Web page without reloading the entire page.

The following code, in other browsers, is normal, but there are strange problems in IE8.

$.ajax ({
url:dataurl,
Data:encodeuri (currentjsonform),
dataType: ' JSON ',
success:function (item) {
debugger;
....
}

After careful investigation, NI is IE8 the existence of Ajax caching problem. NI, executed here, in fact, and did not access our background code, but used the results of the previous cache, debugging in the background, there is no response, only to find that this problem!!!! IE8 is willing to fall.

But strangely, many places are such code, why only here is cached, but the other place does not have the cache problem?

Workaround:

1.

 
 

2. Parameter plus attribute: Cache:false

$.ajax ({
url:dataurl,
Data:encodeuri (currentjsonform),
dataType: ' JSON ',
cache:false,
Success:function (item) {
debugger;
....
}
});

3. You can also add a time stamp to the URL followed by the method.

Lesson:

Programmers really should: cross the road to look both ways!

Don't be too trusting with default values, what attributes are required, be sure to indicate. So it's best to point each time: Cache:false, or every JS page to ensure that at the beginning of the execution:

 
 

In fact, the path with the time stamp or random number of methods, sometimes unreliable! Maybe the browser will ignore it. Anyway, IE8 encountered the URL with timestamp failure.

The above is a small set to introduce the IE8 under the AJAX cache problem, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.