2010-08-30 168 views

回答

3

這是kludgey但應該工作:

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(); 

這可以被擴展,使其一個jQuery插件。

+0

jQuery ajax設置默認沒有所有選項,例如,如果您添加了「成功」處理程序,它仍然會應用:) – 2010-08-31 00:53:15