Home >Web Front-end >JS Tutorial >The ajax page does not refresh and encounters the problem of data not updating due to Ajax cache under IE_jquery
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