简体   繁体   中英

Browser cache issue in IE

I have this JavaScript code:

  $('#selectionoptions').change(function() {
  var courseId = $(this).val();
  $.get('../php/lecturer_getcourse_info.php',
      { course_id: $(this).val() },
      function(courseData) {
          var description = courseData.description;
          $("#coursecontent").html(description);
          ...

Assume I can also modify 'description' and save it back to the db. Now, on Firefox every time I refresh the page I see the correct description; but on IE I have to clear the cache before I see the correct description....

How can I fix this?

The reason being in IE you have to false the Ajax Calls not to cache.

Use this:

$.ajaxSetup({
    // Disable caching of AJAX responses
    cache: false
});

or use a completely different ajax call rather than $.get such as:

$.ajax({
  url: "test.html",
  success: function(data){
    alert('data returned!');
  },
  cache: false
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM