Home  >  Article  >  Web Front-end  >  Solution to the cache problem where Ajax cannot refresh data under IE9

Solution to the cache problem where Ajax cannot refresh data under IE9

亚连
亚连Original
2018-05-25 15:34:081498browse

Use jQuery's getJSON to regularly obtain data from the background and refresh the interface. However, the data cannot be refreshed under IE9. The reason is caching problems. Here is the solution

Use jQuery's getJSON to regularly obtain data from the background and refresh the interface. Refresh the interface. When using the following method, there is no problem under Chrome and Firefox, but the data cannot be refreshed under IE9


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


Reason Yes, under IE9, when making an Ajax request, if it is the same as the previous request, the data will not be obtained from the browser, but directly from the local. Therefore, if a timestamp is added to the request, IE9 will think it is different. The request, the code is as follows:


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

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

Related articles:

AJAX submission form data example analysis

ajax cross-domain (same basic domain name) form submission Method

Ajax loading external page pop-up layer effect implementation method

The above is the detailed content of Solution to the cache problem where Ajax cannot refresh data under IE9. For more information, please follow other related articles on the PHP Chinese website!

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