jQuery在IE中缓存AJAX请求,即使缓存:“false”已设置

时间:2010-05-06 15:29:20

标签: jquery ajax internet-explorer caching

我有以下代码

$.ajax({type: "GET",
  url: "/" + filename,
  dataType: "xml",
  cache: "false",
  success: function(xml)
{
    /* Parsing code here */
}});

在Chrome等中,请求不会被缓存,但它们位于IE中。我正确地构建了我的请求吗?

2 个答案:

答案 0 :(得分:22)

cache应该是布尔值,而不是字符串:

$.ajax({type: "GET",
  url: "/" + filename,
  dataType: "xml",
  cache: false,
  success: function(xml){
    /* Parsing code here */
  }  
});

答案 1 :(得分:0)

也许是你要返回的xml文件的mimetype? http://www.nerdydork.com/ie-json-caching-bug.html

我博客上的一位评论者建议在json请求中添加一个时间字符串:

  

我不会相信设置   在.ajaxSetup中缓存到关闭....

     

所以只需在结尾添加一个时间字符串   每个json请求,例如

     

$ .getJSON('/ url /',{data:123,t:   (new Date())。getTime()},   function(data){//做任何事情});

相关问题