You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/Ajax_Events.html
+7-7
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
"title": "Ajax Events"
4
4
}
5
5
</script>
6
-
<p>Ajax requests produce a number of different events that you can subscribe to. Here's a full list of the events and in what order they are broadcast.</p>
6
+
<p>Ajax requests produce a number of different events that you can subscribe to. Here's a full list of the events and in what order they are triggered.</p>
7
7
<p>There are two types of events:</p>
8
8
<h3>Local Events</h3>
9
9
<p>These are callbacks that you can subscribe to within the Ajax request object, like so:</p>
@@ -18,11 +18,11 @@ <h3>Local Events</h3>
18
18
});
19
19
</code></pre>
20
20
<h3>Global Events</h3>
21
-
<p>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:</p>
22
-
<pre> $("#loading").bind("ajaxSend", function(){
23
-
$(this).show();
21
+
<p>These events are triggered on the <code>document</code>, calling any handlers which may be listening. You can listen for these events like so:</p>
22
+
<pre> $(document).bind("ajaxSend", function(){
23
+
$("#loading").show();
24
24
}).bind("ajaxComplete", function(){
25
-
$(this).hide();
25
+
$("#loading").hide();
26
26
});
27
27
</pre>
28
28
<p>Global events can be disabled for a particular Ajax request by passing in the global option, like so:</p>
@@ -33,10 +33,10 @@ <h3>Global Events</h3>
33
33
});
34
34
</code></pre>
35
35
<h3>Events</h3>
36
-
<p>This is the full list of Ajax events that are broadcast, and in the order in which they are broadcast. The indented events are broadcast for each and every Ajax request (unless a global option has been set). The ajaxStart and ajaxStop events are events that relate to all Ajax requests together.
36
+
<p>This is the full list of Ajax events , and in the order in which they are triggered. The indented events are triggered for each and every Ajax request (unless a global option has been set). The ajaxStart and ajaxStop events are events that relate to all Ajax requests together.
37
37
</p>
38
38
<ul>
39
-
<li><b>ajaxStart</b> (Global Event)<br>This event is broadcast if an Ajax request is started and no other Ajax requests are currently running.
39
+
<li><b>ajaxStart</b> (Global Event)<br>This event is triggered if an Ajax request is started and no other Ajax requests are currently running.
40
40
<ul>
41
41
<li><b>beforeSend</b> (Local Event)<br>This event, which is triggered before an Ajax request is started, allows you to modify the XMLHttpRequest object (setting additional headers, if need be.)</li>
42
42
<li><b>ajaxSend</b> (Global Event)<br>This global event is also triggered before the request is run.</li>
0 commit comments