Reputation: 10412
I am working on a website, I need to call a service via Jquery ajax to read data.
I am doing the following:
$.ajax({
type: "GET",
async: "true",
dataType: 'json',
url: urlString,
beforeSend : function (){
},
success: function (data) {
LoadData(data);
},
failure: function (request, status, error) {
alert("Request failed. Please try again later.");
},
complete: function () {
}
});
The request is working properly.
However when I call it again with the same URL the request goes directly to the "success" without passing through the webservice. Its like the data was cached from the previous request and it is returning it directly.
For the server side, I am using a WCF webservice with Entity framework 6.0 and stored procedures to read from the database
My questions are :
Thanks for any clarifications
Upvotes: 2
Views: 2589
Reputation: 44740
As you are making a Get call, it will get cached by your browser(client behavior).
You can use cache: false
in your call
$.ajax({
type: "GET",
async: "true",
cache: false, <---------
Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters
Upvotes: 0
Reputation: 97717
cache
to false
$.ajax({
type: "GET",
cache: false,
async: "true",
dataType: 'json',
url: urlString,
beforeSend : function (){
},
success: function (data) {
LoadData(data);
},
failure: function (request, status, error) {
alert("Request failed. Please try again later.");
},
complete: function () {
}
});
Upvotes: 4