2

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.

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

My mistake there, i meant "cache:true". I'll update the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.