jQuery ajax - jQuery.ajaxSetup() method
Example
Set default URL and success function for all AJAX requests:
$("button").click(function(){ $.ajaxSetup({url:"demo_ajax_load.txt",success:function(result){ $("div").html(result);}}); $.ajax(); });
Definition and Usage
The jQuery.ajaxSetup() method sets global AJAX default options.
Syntax
jQuery.ajaxSetup(name:value, name:value, ...)
Example
Set the default AJAX request address to "/xmlhttp/", disable the triggering of global AJAX events, and use POST instead of the default GET method. No option parameters are set for subsequent AJAX requests:
$.ajaxSetup({ url: "/xmlhttp/", global: false, type: "POST" }); $.ajax({ data: myData });
Parameter | Description |
---|---|
name:value | Optional. Use name/value pairs to specify the settings of AJAX requests. |
Note:Parameters see '$.ajax' Description.