Reputation: 42450
I'm making a JSON-P request to an API via jQuery AJAX
$('#fetch').click(function(){
$.ajax({
url: 'http://abettertms.com/api2/terms',
dataType: 'jsonp',
success: function(){
console.log("success");
},
error: function() { console.log('error'); }
});
});
Debugging using the Chrome console shows the ajax request is made to
http://abettertms.com/api2/terms?callback=jQuery1710946886689402163_1328157759295&_=1328157761647
with the extra parameter &_=1328157761647
. Why is jQuery adding that? The API I'm calling is my own, so in a crunch I can edit the API to ignore the extraneous parameter, but I'd prefer not having to resort to that.
Upvotes: 0
Views: 2494
Reputation: 100175
Cache Default: true, false for dataType 'script' and 'jsonp'
If set to false, it will force requested pages not to be cached by the browser. Setting cache to false also appends a query string parameter, "_=[TIMESTAMP]", to the URL. See cache param in following link.
Ref: jquery ajax
Upvotes: 2
Reputation:
It's adding that to prevent the browser from caching those responses. It's probably a timestamp value, generated to be different every time you make that jsonp call. Why is in the way? Maybe there are alternatives to whatever your problem is.
See if it goes away if you add cache:true
as an argument to $.ajax
call.
Upvotes: 1