Reputation: 53
I have some code where I grab some HTML from the server and toss it into my page. This is all done through a jQuery AJAX call that looks similar to the following:
$.ajax({
type: "POST",
url: "/something/someAction?id=" + someID,
dataType:"html",
success: function(html) {
$("#container").html(html);
}
});
In that HTML that I get back from the server, there may be one or more script tags. When these are placed on the page, the script associated with the 'src' attribute are properly retrieved.
The issue is that a query string is appended to each of these scripts which causes the script to never be cached. The query string is an underscore with a somewhat random number as the value. Is there a way to have the scripts loaded through AJAX cache properly and not have the query string appended?
I have attempted using "cache:true" but that didn't work.
Upvotes: 2
Views: 307
Reputation: 11
I think you need to set cache to true, not false. From the api reference at: http://api.jquery.com/jQuery.ajax/
Setting cache to false also appends a query string parameter, _=[TIMESTAMP]
, to the URL
Upvotes: 1