How can I modify the default values of options for the $.ajax()
function?
如何修改$ .ajax()函数的选项的默认值?
Ideally to do something similar to:
理想情况下做类似的事情:
//set ajax async to false
$(someSelector).load(url, data, function(){});
//set ajax async to true
to allow me to carry out .post()
synchronously.
允许我同步执行.post()。
2 个解决方案
#1
25
You want ajaxSetup
你想要ajaxSetup
$.ajaxSetup({
url: "/xmlhttp/",
global: false,
type: "POST"
});
$.ajax({ data: myData });
#1
25
You want ajaxSetup
你想要ajaxSetup
$.ajaxSetup({
url: "/xmlhttp/",
global: false,
type: "POST"
});
$.ajax({ data: myData });