How to set cache false for getJSON in jQuery?
Your code just needs a trigger for it to be enabled.
This will allow you to disable cache in all future ajax
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
Hope it helps :)
You can use either this, that will disable cache globally:
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
or that, instead of $.getJSON
, to disable the cache just for such request:
$.ajax({
cache: false,
url: "/path/to.json",
dataType: "json",
success: function(data) {
...
}
});