Reputation: 47773
I'm running an ASP.NET MVC site via IIS Express.
So for example I set up this test page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" language="javascript" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var carServiceUrl = "http://localhost:43889/cars";
$(document).ready(function ()
{
$.ajaxSetup(
{
cache: false,
dataType: "json"
contentType: "application/json"
});
});
get();
function get()
{
var url = carServiceUrl;
$.ajax({
cache: false,
type: "GET",
async: true,
url: carServiceUrl,
dataType: "json",
success: onGetCarsSuccess
});
}
</script>
</body>
</html>
The problem is when I launch FireBug, and I load this page, the get() is getting fired but the request has some kind of appended value to it in the querystring (e.g. http://localhost:43889/cars?_=1381820301163
) and I have no idea how it's getting there. I don't know if it's because I'm running this in an MVC project or that I'm running all this via IIS Express or what. I usually use straight IIS so not sure.
I'm not sure why it's even appending ?_=1381820301163
to the request. I never specified that in my jQuery call.
Upvotes: 3
Views: 1436
Reputation: 151
From the jQuery ajax documentation:
http://api.jquery.com/jQuery.ajax/
cache (default: true, false for dataType 'script' and 'jsonp')
Type: Boolean
If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
Upvotes: 4
Reputation: 3968
try remove cache: false
It works by appending "_={timestamp}" to the GET parameters.
see http://api.jquery.com/jQuery.ajax/
Upvotes: 3