4

I have a ajax call cacheing issue in IE 10. For that solution is to pass cache: false in ajax call. I am facing issue with that. How can I pass Cache: false in that?

$.getJSON(url , function(data){ //some code here }
Aamir Shahzad
  • 6,683
  • 8
  • 47
  • 70

4 Answers4

7

Try like this:

$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

i.e, you need to call the jQuery.ajaxSetup() method and pass the value false to the cache property which will causes jQuery to disable caching on ajax calls.

As answered here by Jitesh you can try this:

$.ajaxSetup({ cache: true});
$.getJSON("/MyQueryUrl",function(data,item) {
     // do stuff with callback data
     $.ajaxSetup({ cache: false});
   });
Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
3

You can't pass any configuration parameters to $.getJSON. As the documentation states, it is a shorthand function for this:

$.ajax({
  dataType: "json",
  url: url,
  data: data,
  success: success
})

So you could just use that code and then set cache: false or set it globally with $.ajaxSetup.

Knelis
  • 6,782
  • 2
  • 34
  • 54
  • 4
    But seriously don't use `$.ajaxSetup`: *Set default values for future Ajax requests. Its use is not recommended*. – Erik Philips Apr 13 '15 at 06:44
1
$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

OR:

$.ajax({
    type: "GET",
    cache: false,
    url: "yourURL",
    //other settings
    success: function(data) {
      //do something with data
    }
});
user4341206
  • 647
  • 1
  • 7
  • 26
-1
JSONObject  jsobj = new JSONObject();
JSONArray  jsobjs = new JSONArray();

I had a similar issue. I tried all the above suggestions but problem was not resolved. Then I found that in my servlet class I was declaring above two objects at class level. I moved these declarations inside doPost() method. The issue got resolved. !!!

Jithin Raj P R
  • 6,667
  • 8
  • 38
  • 69