I have a page that, at the user's request, opens a dialog box and loads an external file into it using jQuery's load() method.
The external file contains links to scripts (it can work as a standalone page, too) and that's fine, only that jQuery forces those scripts to be loaded (by adding a timestamp) even if they have been loaded already.
I need to tell jQuery to allow caching when it sees these scripts. The answer to a bug report suggests using
$.ajaxSetup({ cache: true })
…which does work, but changes the setting for all future AJAX requests. Is there a way to do something like:
// Get current setting - code not valid but is what I want
var defaultCache = $.ajaxSetup("cache");
$.ajaxSetup({cache:true}); // Now set it to what I want
// do stuff…
$.ajaxSetup({cache:defaultCache}); // Set it back to the default
$. ajax({ type: 'POST', url: 'page. php', data: stuff, success: function( data ) { }, error: function(xhr, status, error) { // check status && error }, dataType: 'text' });
jQuery ajaxSetup() Method The ajaxSetup() method sets default values for future AJAX requests.
data : The data to send to the server when performing the Ajax request. dataFilter : A function to be used to handle the raw response data of XMLHttpRequest. dataType : The type of data expected back from the server.
you can do this:
$.ajaxSetup()['cache']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With