The jQuery.ajaxSetup( options ) method sets global settings for future AJAX requests.
Here is the simple syntax to use this method:
$.ajaxSetup( options )
Here is the description of all the parameters used by this method:
options: A set of key/value pairs that configure the Ajax request. All options are optional.
Here is the list of option which could be used as key/value pairs. Except URL, rest of the parameters are optional:
Assuming we have following HTML content in /jquery/result.html file:
<h1>THIS IS RESULT...</h1>
Following is a simple example a simple showing the usage of this method. Here we make use of success handler to populate returned HTML:
<html> <head> <script type="text/javascript" src="../../js/jquery-2.2.0.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("#driver").click(function(event){ // Do global setting. $.ajaxSetup({ url: "/jquery/result.html" }); $.ajax( { success:function(data) { $('#stage').html(data); } }); }); }); </script> </head> <body> <p>Click on the button to load result.html file:</p> <div id="stage" style="background-color:blue;"> STAGE </div> <input type="button" id="driver" value="Load Data" /> </body> </html>
Your Query was successfully sent!