Ajax cache problems and solutions under IE8, ie8ajax

Source: Internet
Author: User

Ajax cache problems and solutions under IE8, ie8ajax

Ajax Introduction

AJAX is "Asynchronous Javascript And XML" (Asynchronous JavaScript And XML), which is a Web page development technology used to create interactive web applications.

AJAX = Asynchronous JavaScript and XML (subset of standard General Markup Language ).

AJAX is a technology used to create fast dynamic web pages.

By performing a small amount of data exchange with the server in the background, AJAX can implement asynchronous updates on webpages. This means that you can update a part of a webpage without reloading the entire webpage.

The following code is normal in other browsers, but there is a strange problem in IE8.

$.ajax({url:dataUrl,data:encodeURI(currentjsonform),dataType:'JSON',success:function(item){debugger;....}}); 

After careful troubleshooting, Nima is an ajax cache problem in ie8. Nima, the execution is actually not accessing our background code. Instead, it uses the previously cached results and does not respond during background debugging, this problem is discovered !!!! IE8 is willing to fall.

But it is strange that such code is used in many places. Why is it cached only here, and there is no cache problem in other places?

Solution:

1.

$.ajaxSetup({ cache: false }); 

2. Attribute added to the parameter: cache: false

$.ajax({url:dataUrl,data:encodeURI(currentjsonform),dataType:'JSON',cache:false,success:function(item){debugger;....}});

3. You can add Timestamp and other methods to the url.

Lessons learned:

Programmers really should: cross the road to view on both sides!

Do not trust the default value. Specify the attributes required. Therefore, it is best to specify cache: false every time, or ensure that each js page is executed at the beginning:

$.ajaxSetup({ cache: false }); 

In fact, the path with a timestamp or random number is sometimes unreliable! Maybe the browser will ignore it. IE8 may encounter Invalid url with a timestamp multiple times.

The above is a small Editor to introduce to you the Ajax cache problem under IE8, I hope to help you, if you have any questions, please leave a message, the small editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.