Skip to main content

Bug Tracker

Side navigation

#7201 closed bug ()

Opened October 15, 2010 12:30PM UTC

Closed November 11, 2010 11:09PM UTC

Last modified January 31, 2011 05:55PM UTC

Exception thrown by $.ajax.error callback cannot be caught by outer try...catch (for a synchronous request)

Reported by: Owned by:
Priority: low Milestone: 1.5
Component: ajax Version: 1.5
Keywords: Cc:
Blocked by: Blocking:

Making a synchronous $.ajax request that completes with a server exception, an exception thrown inside the "error" callback cannot be caught by an outer try...catch.

That is because in 1.4.2 the result of the request is handled in an asynchronous manner (by attaching a handler to the xhr.onreadystatechange event, even for synchronous requests) thus making it impossible to catch an exception from the error callback.

A possible fix for this could be modifying this line:

var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {


var onreadystatechange = function( isTimeout ) {

and after the onreadystatechange code block, this should be added:

if (s.async)


xhr.onreadystatechange = onreadystatechange;


Attachments (0)
Change History (5)

Changed October 15, 2010 03:45PM UTC by addyosmani comment:1

component: unfiledajax
owner: →
priority: undecidedlow
status: newpending

Please provide a valid test case that we can use to verify the behavior described in your ticket.

Changed October 21, 2010 10:57PM UTC by snover comment:2


Retargeting due to severity of regressions in 1.4.3.

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:3

status: pendingclosed

Automatically closed due to 14 days of inactivity.

Changed January 31, 2011 05:53PM UTC by john comment:4


There wasn't a 1.4.5 release, was actually 1.5.

Changed January 31, 2011 05:55PM UTC by john comment:5


There was no 1.4.5 release, was actually 1.5.