Skip to content

Commit 374a633

Browse files
committed
.ajaxError(): Note possible values of thrownError arg
Closes #12
1 parent 3813a0b commit 374a633

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

entries/ajaxError.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
$( "div.log" ).text( "Triggered ajaxError handler." );
2020
});</code></pre>
2121
<p>Now, make an Ajax request using any jQuery method:</p>
22-
<pre><code>$( "button.trigger" ).click(function() {
22+
<pre><code>$( "button.trigger" ).on( "click", function() {
2323
$( "div.result" ).load( "ajax/missing.html" );
2424
});</code></pre>
2525
<p>When the user clicks the button and the Ajax request fails, because the requested file is missing, the log message is displayed.</p>
2626
<p><strong>As of jQuery 1.8, the <code>.ajaxError()</code> method should only be attached to <code>document</code>.</strong></p>
27-
<p>All <code>ajaxError</code> handlers are invoked, regardless of what Ajax request was completed. To differentiate between the requests, use the parameters passed to the handler. Each time an <code>ajaxError</code> handler is executed, it is passed the event object, the <code>jqXHR</code> object (prior to jQuery 1.5, the <code><abbr title="XMLHttpRequest">XHR</abbr></code> object), and the settings object that was used in the creation of the request. If the request failed because JavaScript raised an exception, the exception object is passed to the handler as a fourth parameter. For example, to restrict the error callback to only handling events dealing with a particular URL:</p>
27+
<p>All <code>ajaxError</code> handlers are invoked, regardless of what Ajax request was completed. To differentiate between the requests, use the parameters passed to the handler. Each time an <code>ajaxError</code> handler is executed, it is passed the event object, the <code>jqXHR</code> object (prior to jQuery 1.5, the <code><abbr title="XMLHttpRequest">XHR</abbr></code> object), and the settings object that was used in the creation of the request. When an HTTP error occurs, the fourth argument (<code>thrownError</code>) receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." For example, to restrict the error callback to only handling events dealing with a particular URL:</p>
2828
<pre><code>$( document ).ajaxError(function(event, jqxhr, settings, exception) {
2929
if ( settings.url == "ajax/missing.html" ) {
3030
$( "div.log" ).text( "Triggered ajaxError handler." );

0 commit comments

Comments
 (0)