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!