Reputation: 6834
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 }
Upvotes: 4
Views: 9524
Reputation: 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. !!!
Upvotes: -1
Reputation: 172608
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});
});
Upvotes: 7
Reputation: 7149
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
.
Upvotes: 3
Reputation: 647
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
OR:
$.ajax({
type: "GET",
cache: false,
url: "yourURL",
//other settings
success: function(data) {
//do something with data
}
});
Upvotes: 1