jQuery caches AJAX request in IE even though cache: “false” is set

前端 未结 2 1644
予麋鹿
予麋鹿 2020-12-11 16:15

I have the following code

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


        
相关标签:
2条回答
  • 2020-12-11 16:45

    Perhaps it is the mimetype of the xml file you are returning? http://www.nerdydork.com/ie-json-caching-bug.html

    One commenter on my blog suggested adding a time string to the json request:

    I’m not going to trust in setting the cache to off in .ajaxSetup….

    So just add a time string at the end of each json request, e.g.

    $.getJSON( ‘/url/’, { data: 123, t: (new Date()).getTime() }, function(data) { //do whatever } );

    0 讨论(0)
  • 2020-12-11 16:47

    cache should be a boolean, not a string:

    $.ajax({type: "GET",
      url: "/" + filename,
      dataType: "xml",
      cache: false,
      success: function(xml){
        /* Parsing code here */
      }  
    });
    
    0 讨论(0)
提交回复
热议问题