Home > Web Front-end > JS Tutorial > Ajax caching problems and solutions under IE8

Ajax caching problems and solutions under IE8

亚连
Release: 2018-05-23 16:54:10
Original
1637 people have browsed it

AJAX stands for "Asynchronous Javascript And XML" (asynchronous JavaScript and XML), which refers to a web development technology for creating interactive web applications. Next, this article will introduce to you the Ajax cache problem and solution under IE8. Let’s take a look at it

Introduction to Ajax

AJAX means “Asynchronous "Javascript And XML" (asynchronous JavaScript and XML) refers to a web development technology for creating interactive web applications.

AJAX = Asynchronous JavaScript and XML (a subset of Standard Universal Markup Language).

AJAX is a technology for creating fast, dynamic web pages.

By exchanging a small amount of data with the server in the background, AJAX can enable asynchronous updates of web pages. This means that parts of a web page can be updated without reloading the entire page.

The code below works fine in other browsers, but strange problems occur in IE8.

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

After careful investigation, it turned out to be an ajax cache problem in IE8. Damn it, when the execution reaches this point, in fact, it does not access our background code, but uses the previously cached results. When debugging in the background, there is no response, and I found out that this is the problem! ! ! ! IE8 is willing to drop.

But the strange thing is that there are many places with such code. Why is it cached only here and not in other places?

Solution:

##1.

$.ajaxSetup({ cache: false });
Copy after login
Copy after login

2. Parameters plus attributes: cache: false


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

3. You can also add it after the url Timestamp and other methods.


Lesson:

Programmers really should: look both ways when crossing the road!


Don’t trust the default value too much. Be sure to specify what attributes are needed. So it is best to specify: cache:false every time, or each js page is guaranteed to be executed once at the beginning:

$.ajaxSetup({ cache: false });
Copy after login
Copy after login

In fact, the path has a timestamp Or the random number method is sometimes unreliable! Maybe the browser ignores it. Anyway, IE8 has encountered the situation where the URL with timestamp fails many times.


The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Ajax cache problem under IE8/IE9

IE8 cannot be refreshed every time using ajax access Problem

Quick solution to Ajax submission garbled code under IE

The above is the detailed content of Ajax caching problems and solutions under IE8. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template