How to change $.ajax() default settings?
How can I modify the default values of options for the $.ajax()
function?
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()
synchronous开发者_运维知识库ly.
You want ajaxSetup
$.ajaxSetup({
url: "/xmlhttp/",
global: false,
type: "POST"
});
$.ajax({ data: myData });
Try using $.ajaxSetup()
$.ajaxSetup({
async: false
});
精彩评论