Exceptions thrown in jQuery AJAX callbacks swallowed?

Posted by MikeWyatt on Stack Overflow See other posts from Stack Overflow or by MikeWyatt
Published on 2010-04-27T14:22:53Z Indexed on 2010/04/27 15:33 UTC
Read the original article Hit count: 295

Filed under:
|
|
|

Is there any way to handle exceptions thrown from AJAX callbacks in jQuery, other than adding a try..catch block to each callback? The error function is not called in this situation.

$.ajax(
{
    url: 'myurl.rails',
    success: function( data )
    {
        throw 'Oh no!';
    },
    error: function ( xhr, textStatus, errorThrown )
    {
        console.log( 'AJAX call failed', xhr, textStatus, errorThrown );
    }               
} );

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery