Home >Web Front-end >JS Tutorial >jQuery.ajaxSetup() method
function for all AJAX requests :
$("button").click(function(){ $.ajaxSetup({url:"demo_ajax_load.txt",success:function(result){ $("p").html(result);}}); $.ajax(); });Try it yourself
jQuery.ajaxSetup() Method sets global AJAX default options.
SyntaxjQuery.ajaxSetup(name:value, name:value, ...)
xmlhttp/" and prohibit triggering of global AJAX Events, use POST instead of the default GET method. Subsequent AJAX requests will no longer set any option parameters:
$.ajaxSetup({ url: "/xmlhttp/", global: false, type: "POST" });$.ajax({ data: myData });
参数 | 描述 |
---|---|
name:value | 可选。使用名称/值对来规定 AJAX 请求的设置。 |
注释:参数见 '$.ajax' 说明。
The above is the detailed content of jQuery.ajaxSetup() method. For more information, please follow other related articles on the PHP Chinese website!