#7201 closed bug
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: |
Description
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 ) {
into:
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 12 years ago by
Component: | unfiled → ajax |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
comment:2 Changed 12 years ago by
Milestone: | 1.4.4 → 1.4.5 |
---|
Retargeting due to severity of regressions in 1.4.3.
comment:3 Changed 12 years ago by
Status: | pending → closed |
---|
Automatically closed due to 14 days of inactivity.
comment:14 Changed 11 years ago by
Version: | 1.4.2 → 1.5 |
---|
There wasn't a 1.4.5 release, was actually 1.5.
comment:15 Changed 11 years ago by
Milestone: | 1.4.5 → 1.5 |
---|
There was no 1.4.5 release, was actually 1.5.
Please provide a valid test case that we can use to verify the behavior described in your ticket.