The default behavior of jQuery AJAX requests is that they run asynchronously, which means that you can run many AJAX requests or other JavaScript processes at the same time. If you call the $.ajax()
function with the default settings, any JavaScript code after this AJAX request will be executed without waiting for a response. In most cases, this is the desired behavior, but there are some situations where you will want to prevent further execution until there has been a response to the AJAX call. This may be because you require some information from the first AJAX call to make a second, or just that your application requires data from the first call before it can run the second. There are a few ways to achieve this; refer to the Caching JSON and AJAX requests recipe of this chapter to see a very basic implementation where you simply turn off the asynchronous behavior. The preferred implementation though uses jQuery's .when()
and .done()
functions.
jQuery 2.0 Development Cookbook
By :
jQuery 2.0 Development Cookbook
By:
Overview of this book
Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Document Object Model Manipulation
Interacting with the User by Making Use of jQuery Events
Loading and Manipulating Dynamic Content with AJAX and JSON
Adding Attractive Visuals with jQuery Effects
Form Handling
User Interface
User Interface Animation
Understanding Plugin Development
jQuery UI
Working with jQuery Mobile
Index
Customer Reviews