如何从jQuery的ajaxSetup获取当前值 [英] How to get a current value from jQuery's ajaxSetup

查看:112
本文介绍了如何从jQuery的ajaxSetup获取当前值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,可根据用户的请求打开一个对话框,并使用jQuery的load()方法将一个外部文件加载到其中.

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.

外部文件包含指向脚本的链接(也可以作为独立页面使用),这很好,只有jQuery强制这些脚本被加载(通过添加时间戳),即使它们已经被加载.

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.

我需要告诉jQuery在看到这些脚本时允许缓存. 错误报告的答案建议使用

I need to tell jQuery to allow caching when it sees these scripts. The answer to a bug report suggests using

$.ajaxSetup({ cache: true })

…确实有效,但是会更改以后所有AJAX请求的设置.有没有办法做类似的事情:

…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

推荐答案

您可以执行以下操作:

$.ajaxSetup()['cache']

这篇关于如何从jQuery的ajaxSetup获取当前值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆