ignore ajax setup
is there any way of ignoring the optio开发者_StackOverflow中文版ns set with $.ajaxSetup for a specific request?
This is kludgey but should work:
var origAjaxSettings = {};
function ajaxSettingsDisable() {
jQuery.extend(origAjaxSettings, jQuery.ajaxSettings);
jQuery.ajaxSettings = {};
}
function ajaxSettingsEnable() {
jQuery.extend(jQuery.ajaxSettings, origAjaxSettings);
origAjaxSettings = {};
}
//ajax request of any sort
ajaxSettingsDisable();
$.ajax({
//Ajax request settings
});
ajaxSettingsEnable();
This could be extended to make it a jQuery plug-in.
There isn't any built-in functionality to do this. The very first thing any $.ajax()
call does is merge options with $.ajaxSettings
, there's no bypass for this.
Any of the $.ajax()
shorthand methods (.load()
, $.post()
, etc) are still calling $.ajax()
underneath, so they're in the same boat.
精彩评论