- 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 the difference between Local Events and Global Events in jQuery?
Ajax requests produce a number of different events that you can subscribe to. There are two types of events:
Local Events
These are callbacks that you can subscribe to within the Ajax request object.
$.ajax({ beforeSend: function(){ // Handle the beforeSend event }, complete: function(){ // Handle the complete event } // ...... });
Global Events
These events are broadcast to all elements in the DOM, triggering any handlers which may be listening. You can listen for these events like so:
$("#loading").bind("ajaxSend", function(){ $(this).show(); }).bind("ajaxComplete", function(){ $(this).hide(); });
Global events can be disabled, for a particular Ajax request, by passing in the global option, like so:
$.ajax({ url: "test.html", global: false, // ... });
Advertisements