Skip to content

Commit 28a2302

Browse files
committed
Add Ajax_Events page and change hrefs to point to it
* They were pointing to http://docs.jquery.com/Ajax_Events * Fixes #165
1 parent a109208 commit 28a2302

8 files changed

Lines changed: 63 additions & 11 deletions

File tree

entries/ajaxComplete.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<desc>The function to be invoked.</desc>
88
</argument>
99
</signature>
10-
<desc>Register a handler to be called when Ajax requests complete. This is an <a href="http://docs.jquery.com/Ajax_Events">AjaxEvent</a>.</desc>
10+
<desc>Register a handler to be called when Ajax requests complete. This is an <a href="/Ajax_Events">AjaxEvent</a>.</desc>
1111
<longdesc>
1212
<p>Whenever an Ajax request completes, jQuery triggers the <code>ajaxComplete</code> event. Any and all handlers that have been registered with the <code>.ajaxComplete()</code> method are executed at this time.</p>
1313
<p>To observe this method in action, set up a basic Ajax load request:</p>

entries/ajaxError.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<desc>The function to be invoked.</desc>
88
</argument>
99
</signature>
10-
<desc>Register a handler to be called when Ajax requests complete with an error. This is an <a href='http://docs.jquery.com/Ajax_Events'>Ajax Event</a>.</desc>
10+
<desc>Register a handler to be called when Ajax requests complete with an error. This is an <a href='/Ajax_Events'>Ajax Event</a>.</desc>
1111
<longdesc>
1212
<p>Whenever an Ajax request completes with an error, jQuery triggers the <code>ajaxError</code> event. Any and all handlers that have been registered with the <code>.ajaxError()</code> method are executed at this time.</p>
1313
<p>To observe this method in action, set up a basic Ajax load request.</p>

entries/ajaxSend.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<desc>The function to be invoked.</desc>
88
</argument>
99
</signature>
10-
<desc>Attach a function to be executed before an Ajax request is sent. This is an <a href='http://docs.jquery.com/Ajax_Events'>Ajax Event</a>.</desc>
10+
<desc>Attach a function to be executed before an Ajax request is sent. This is an <a href='/Ajax_Events'>Ajax Event</a>.</desc>
1111
<longdesc>
1212
<p>Whenever an Ajax request is about to be sent, jQuery triggers the <code>ajaxSend</code> event. Any and all handlers that have been registered with the <code>.ajaxSend()</code> method are executed at this time.</p>
1313
<p>To observe this method in action, set up a basic Ajax load request:</p>

entries/ajaxStart.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<desc>The function to be invoked.</desc>
88
</argument>
99
</signature>
10-
<desc>Register a handler to be called when the first Ajax request begins. This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>.</desc>
10+
<desc>Register a handler to be called when the first Ajax request begins. This is an <a href="/Ajax_Events">Ajax Event</a>.</desc>
1111
<longdesc>
1212
<p>Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the <code>ajaxStart</code> event. Any and all handlers that have been registered with the <code>.ajaxStart()</code> method are executed at this time.</p>
1313
<p>To observe this method in action, set up a basic Ajax load request:</p>

entries/ajaxStop.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<entry type="method" name="ajaxStop" return="jQuery">
33
<title>.ajaxStop()</title>
4-
<desc>Register a handler to be called when all Ajax requests have completed. This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>.</desc>
4+
<desc>Register a handler to be called when all Ajax requests have completed. This is an <a href="/Ajax_Events">Ajax Event</a>.</desc>
55
<signature>
66
<added>1.0</added>
77
<argument name="handler()" type="Function">

entries/ajaxSuccess.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<desc>The function to be invoked.</desc>
88
</argument>
99
</signature>
10-
<desc>Attach a function to be executed whenever an Ajax request completes successfully. This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>.</desc>
10+
<desc>Attach a function to be executed whenever an Ajax request completes successfully. This is an <a href="/Ajax_Events">Ajax Event</a>.</desc>
1111
<longdesc>
1212
<p>Whenever an Ajax request completes successfully, jQuery triggers the <code>ajaxSuccess</code> event. Any and all handlers that have been registered with the <code>.ajaxSuccess()</code> method are executed at this time.</p>
1313
<p>To observe this method in action, set up a basic Ajax load request:</p>

entries/jQuery.ajax.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
<property name="beforeSend" type="Function">
2525
<argument name="jqXHR" type="jqXHR"/>
2626
<argument name="settings" type="PlainObject"/>
27-
<desc>A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings maps are passed as arguments. This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>. Returning <code>false</code> in the <code>beforeSend</code> function will cancel the request. <strong>As of jQuery 1.5</strong>, the <code>beforeSend</code> option will be called regardless of the type of request.</desc>
27+
<desc>A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings maps are passed as arguments. This is an <a href="/Ajax_Events">Ajax Event</a>. Returning <code>false</code> in the <code>beforeSend</code> function will cancel the request. <strong>As of jQuery 1.5</strong>, the <code>beforeSend</code> option will be called regardless of the type of request.</desc>
2828
</property>
2929
<property name="cache" default="true, false for dataType 'script' and 'jsonp'" type="Boolean">
3030
<desc>If set to <code>false</code>, it will force requested pages not to be cached by the browser. <strong>Note:</strong> Setting <code>cache</code> to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.</desc>
3131
</property>
3232
<property name="complete" type="Function">
3333
<argument name="jqXHR" type="jqXHR"/>
3434
<argument name="textStatus" type="String"/>
35-
<desc>A function to be called when the request finishes (after <code>success</code> and <code>error</code> callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request (<code>"success"</code>, <code>"notmodified"</code>, <code>"error"</code>, <code>"timeout"</code>, <code>"abort"</code>, or <code>"parsererror"</code>). <strong>As of jQuery 1.5</strong>, the <code>complete</code> setting can accept an array of functions. Each function will be called in turn. This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>.</desc>
35+
<desc>A function to be called when the request finishes (after <code>success</code> and <code>error</code> callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request (<code>"success"</code>, <code>"notmodified"</code>, <code>"error"</code>, <code>"timeout"</code>, <code>"abort"</code>, or <code>"parsererror"</code>). <strong>As of jQuery 1.5</strong>, the <code>complete</code> setting can accept an array of functions. Each function will be called in turn. This is an <a href="/Ajax_Events">Ajax Event</a>.</desc>
3636
</property>
3737
<property name="contents" type="PlainObject" added="1.5">
3838
<desc>A map of string/regular-expression pairs that determine how jQuery will parse the response, given its content type.</desc>
@@ -72,10 +72,10 @@
7272
<argument name="jqXHR" type="jqXHR"/>
7373
<argument name="textStatus" type="String"/>
7474
<argument name="errorThrown" type="String"/>
75-
<desc>A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides <code>null</code>) are <code>"timeout"</code>, <code>"error"</code>, <code>"abort"</code>, and <code>"parsererror"</code>. When an HTTP error occurs, <code>errorThrown</code> receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." <strong>As of jQuery 1.5</strong>, the <code>error</code> setting can accept an array of functions. Each function will be called in turn. <strong>Note:</strong> <em>This handler is not called for cross-domain script and JSONP requests.</em> This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>. </desc>
75+
<desc>A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides <code>null</code>) are <code>"timeout"</code>, <code>"error"</code>, <code>"abort"</code>, and <code>"parsererror"</code>. When an HTTP error occurs, <code>errorThrown</code> receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." <strong>As of jQuery 1.5</strong>, the <code>error</code> setting can accept an array of functions. Each function will be called in turn. <strong>Note:</strong> <em>This handler is not called for cross-domain script and JSONP requests.</em> This is an <a href="/Ajax_Events">Ajax Event</a>. </desc>
7676
</property>
7777
<property default="true" name="global" type="Boolean">
78-
<desc>Whether to trigger global Ajax event handlers for this request. The default is <code>true</code>. Set to <code>false</code> to prevent the global handlers like <code>ajaxStart</code> or <code>ajaxStop</code> from being triggered. This can be used to control various <a href="http://docs.jquery.com/Ajax_Events">Ajax Events</a>.</desc>
78+
<desc>Whether to trigger global Ajax event handlers for this request. The default is <code>true</code>. Set to <code>false</code> to prevent the global handlers like <code>ajaxStart</code> or <code>ajaxStop</code> from being triggered. This can be used to control various <a href="/Ajax_Events">Ajax Events</a>.</desc>
7979
</property>
8080
<property name="headers" type="PlainObject" default="{}" added="1.5">
8181
<desc>A map of additional header key/value pairs to send along with the request. This setting is set before the <code>beforeSend</code> function is called; therefore, any values in the headers setting can be overwritten from within the <code>beforeSend</code> function.</desc>
@@ -121,7 +121,7 @@
121121
<argument name="data" type="Object"/>
122122
<argument name="textStatus" type="String"/>
123123
<argument name="jqXHR" type="jqXHR"/>
124-
<desc>A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the <code>dataType</code> parameter; a string describing the status; and the <code>jqXHR</code> (in jQuery 1.4.x, XMLHttpRequest) object. <strong>As of jQuery 1.5</strong>, <em>the success setting can accept an array of functions. Each function will be called in turn.</em> This is an <a href="http://docs.jquery.com/Ajax_Events">Ajax Event</a>.</desc>
124+
<desc>A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the <code>dataType</code> parameter; a string describing the status; and the <code>jqXHR</code> (in jQuery 1.4.x, XMLHttpRequest) object. <strong>As of jQuery 1.5</strong>, <em>the success setting can accept an array of functions. Each function will be called in turn.</em> This is an <a href="/Ajax_Events">Ajax Event</a>.</desc>
125125
</property>
126126
<property name="timeout" type="Number">
127127
<desc>Set a timeout (in milliseconds) for the request. This will override any global timeout set with <a href="http://api.jquery.com/jQuery.ajaxSetup">$.ajaxSetup()</a>. The timeout period starts at the point the <code>$.ajax</code> call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. <strong>In jQuery 1.4.x and below,</strong> the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. <strong>In Firefox 3.0+ only,</strong> script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.</desc>

pages/Ajax_Events.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script>
2+
{
3+
"title": "Ajax Events"
4+
}
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>
7+
<p>There are two types of events:</p>
8+
<h3>Local Events </span></h3>
9+
<p>These are callbacks that you can subscribe to within the Ajax request object, like so:</p>
10+
<pre><code> $.ajax({
11+
beforeSend: function(){
12+
// Handle the beforeSend event
13+
},
14+
complete: function(){
15+
// Handle the complete event
16+
}
17+
// ......
18+
});
19+
</code></pre>
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();
24+
}).bind("ajaxComplete", function(){
25+
$(this).hide();
26+
});
27+
</pre>
28+
<p>Global events can be disabled for a particular Ajax request by passing in the global option, like so:</p>
29+
<pre><code> $.ajax({
30+
url: "test.html",
31+
global: false,
32+
// ...
33+
});
34+
</code></pre>
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.
37+
</p>
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.
40+
<ul>
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+
<li> <b>ajaxSend</b> (Global Event)<br>This global event is also triggered before the request is run.</li>
43+
<li> <b>success</b> (Local Event)<br>This event is only called if the request was successful (no errors from the server, no errors with the data).</li>
44+
<li> <b>ajaxSuccess</b> (Global Event)<br>This event is also only called if the request was successful.</li>
45+
<li> <b>error</b> (Local Event)<br>This event is only called if an error occurred with the request (you can never have both an error and a success callback with a request).</li>
46+
<li> <b>ajaxError</b> (Global Event)<br>This global event behaves the same as the local error event.</li>
47+
<li> <b>complete</b> (Local Event)<br>This event is called regardless of if the request was successful, or not. You will always receive a complete callback, even for synchronous requests.</li>
48+
<li> <b>ajaxComplete</b> (Global Event)<br>This event behaves the same as the complete event and will be triggered every time an Ajax request finishes.</li>
49+
</ul>
50+
</li>
51+
<li><b>ajaxStop</b> (Global Event)<br>This global event is triggered if there are no more Ajax requests being processed.</li>
52+
</ul>

0 commit comments

Comments
 (0)