Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#7201 closed bug

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

Reported by: cipinistor@… Owned by: cipinistor@…
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;


Change History (5)

comment:1 Changed 13 years ago by addyosmani

Component: unfiledajax
Owner: set to cipinistor@…
Priority: undecidedlow
Status: newpending

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

comment:2 Changed 13 years ago by snover


Retargeting due to severity of regressions in 1.4.3.

comment:3 Changed 13 years ago by trac-o-bot

Status: pendingclosed

Automatically closed due to 14 days of inactivity.

comment:14 Changed 12 years ago by john


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

comment:15 Changed 12 years ago by john


There was no 1.4.5 release, was actually 1.5.

Note: See TracTickets for help on using tickets.