In IE9, Ajax cannot refresh the data cache. Solution: ie9ajax

Source: Internet
Author: User

In IE9, Ajax cannot refresh the data cache. Solution: ie9ajax

Use jQuery's getJSON to regularly retrieve data from the background and refresh the interface. When using the following methods, there is no problem in Chrome or Firefox, but the data cannot be refreshed in IE9.

$.getJSON(webApp + "/GetShowData.do?limit=" + limit,function(data){  //******************}

The reason is that, in IE9, if the Ajax request is the same as the previous request, it will not retrieve data from the browser, but directly obtain data from the local. Therefore, when a timestamp is added to a request, IE9 considers it a different request. The Code is as follows:

$.getJSON(webApp + "/GetHccShowData.do?" + <span style="color: #ff0000;">new Date().getTime()</span> + "limit=" + Hcc.limit,function(data){  //******************}

AJAX asynchronously refreshes IE to display only the first data. Why not update

The data you obtained is cached... You can use post instead .. Or change your url
'Zx. aspx? Id = '+ p. value +' & date = '+ new Date ()....

AJAX cache in IE

If AJAX is not used in combination with Web Services, it simply reads another page, which is the same effect for another page to be opened directly from a browser, therefore, your problem has nothing to do with the AJAX method itself, because AJAX is only responsible for reading. As for what the page provides to him, you need to solve the cache problem from the page itself.
The default cache settings are different for several browsers. You can directly add a disabled cache on the page.
HTML
<META HTTP-EQUIV = "pragma" CONTENT = "no-cache">
<META HTTP-EQUIV = "Cache-Control" CONTENT = "no-cache, must-revalidate">
<META HTTP-EQUIV = "expires" CONTENT = "Mon, 23 Jan 1978 12:52:30 GMT">
ASP
<%
Response. Expires =-1
Response. ExpiresAbsolute = Now ()-1
Response. cachecontrol = "no-cache"
%>
PHP
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Cache-Control: no-cache, must-revalidate ");
Header ("Pragma: no-cache ");
JSP
Response. setHeader ("Pragma", "No-Cache ");
Response. setHeader ("Cache-Control", "No-Cache ");
Response. setDateHeader ("Expires", 0 );
How to disable cache in C!
Response. Buffer = true;
Response. ExpiresAbsolute = System. DateTime. Now. AddSeconds (-1 );
Response. Expires = 0;
Response. CacheControl = "no-cache ";
Above

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.