Home >Web Front-end >JS Tutorial >jQuery.ajaxSetup() method

jQuery.ajaxSetup() method

巴扎黑
巴扎黑Original
2017-07-03 11:16:121313browse


##Example

Set the default URL and success

function for all AJAX requests

$("button").click(function(){
  $.ajaxSetup({url:"demo_ajax_load.txt",success:function(result){
    $("p").html(result);}});
  $.ajax();
});
Try it yourself


Definition and usage

jQuery.ajaxSetup() Method sets global AJAX default options.

Syntax

jQuery.ajaxSetup(name:value, name:value, ...)

Example

Set the default address of AJAX requests to "/

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn