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

jQuery.ajaxSetup() method

巴扎黑
Release: 2017-07-03 11:16:12
Original
1328 people have browsed it


##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();
});
Copy after login
Try it yourself


Definition and usage

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

Syntax

jQuery.ajaxSetup(name:value, name:value, ...)
Copy after login

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 });
Copy after login
参数 描述
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!

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template