user535673 user535673 - 1 year ago 100
jQuery Question

How to get a current value from jQuery's ajaxSetup

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

Answer Source

you can do this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download