Home  >  Article  >  Web Front-end  >  The ajax page does not refresh and encounters the problem of data not updating due to Ajax cache under IE_jquery

The ajax page does not refresh and encounters the problem of data not updating due to Ajax cache under IE_jquery

WBOY
WBOYOriginal
2016-05-16 17:46:491010browse

When adding an ajax page without refreshing, I encountered Ajax caching. Because I didn't know IE had this bad problem at first, I struggled for a long time and finally solved the problem.

To summarize the solution:
Using Ajax to request a certain page under IE usually returns the last result due to caching, causing confusion, [i.e. get method When obtaining data, since the sending parameters and address are consistent, the IE browser will fetch it from the cache instead of requesting the server. However, the post method will not cause this problem due to different parameters] and FF will not This happens. In order not to be affected by cache, you can do this:

IE Access Policy:
Internet Options--Browsing History--Settings--Change the option for temporary Internet files to each time When accessing a web page, you can also
1: Add a random function after the page requested by AJAX. We can use the random time function

and add
1 t=Math.random after the URL sent by javascript. ()

For example: 1 URL "&" "t=" Math.random();//or new Date();

in Add www.hake.cc after the URL parameter
1 "?timestamp=" new Date().getTime();


The best method: 1 $ .ajaxSetup({cache:false})
This will be executed for all ajax requests in the page. There is no need to change the completed N interfaces

Statement:
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