- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is jQuery.ajaxSetup() method in jQuery?
The jQuery.ajaxSetup() method sets global settings for future AJAX requests. Here is the description of all the parameters used by this method-
Let’s say we have the following HTML content in result.html file,
<h1>THIS IS RESULT...</h1>
The following is an example showing the usage of this method. Here we make use of success handler to populate returned HTML:
<html> <head> <title>The jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("#driver").click(function(event){ // Do global setting. $.ajaxSetup({ url: "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:#cc0;"> STAGE </div> <input type = "button" id = "driver" value = "Load Data" /> </body> </html>
Advertisements