Side navigation
#5840 closed bug (worksforme)
Opened January 17, 2010 02:25PM UTC
Closed November 01, 2010 05:39AM UTC
Last modified April 26, 2011 12:02PM UTC
ajax callbacks lose exceptions
| Reported by: | borgar | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.4.1 |
| Component: | ajax | Version: | 1.4 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
The following code should throw an error ("DOES_NOT_EXIST is not defined"), but doesn't in Firefox:
$.ajax({
success: function(html){
DOES_NOT_EXIST++;
}
});
This is not a case of jQuery swallowing the error in a try/catch but rather that Firefox seems to loose the error somewhere in it's event handling.
While I think this is a browser bug, I think it needs addressing in jQuery because of the debugging implications: This may hide 1.4 compatibility errors in callbacks from developers upgrading.
Apart from try/catch within the callback itself, the only way I've been able to keep the exception is to defer it with a timeout:
function success() {
// If a local callback was specified, fire it and pass it the data
if ( s.success ) {
try {
s.success.call( callbackContext, data, status, xhr );
} catch (e) {
setTimeout(function(){
throw e;
},0);
}
}
// ...
Attachments (0)
Change History (2)
Changed November 01, 2010 05:39AM UTC by comment:1
| resolution: | → worksforme |
|---|---|
| status: | new → closed |
Changed April 26, 2011 12:02PM UTC by comment:2
I had the same problem; starting Firefox 4 in safe mode solved the problem. Turned out to be the Adblock Plus extension that was swallowing the errors in my case..
test case works for me.