开发者

How to change $.ajax() default settings?

开发者 https://www.devze.com 2023-03-23 21:26 出处:网络
How can I modify the default values of options for the $.ajax() function? Ideally to do something similar to:

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
});
0

精彩评论

暂无评论...
验证码 换一张
取 消