Home
> Uncategorized > JQuery Parsed Ajax Errors
JQuery Parsed Ajax Errors
A very cool code fragment I ran into while looking for something else — funny how that happens.
jQuery Deferreds and the jQuery Promise Method
JQXHR AND THE PROMISE INTERFACE
- $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
- if ( options.parseError ) {
- jqXHR.pipe( null, function( jqXHR, statusText, errorMsg ) {
- var parsed = $.parseJSON( jqXHR.responseText );
- return $.Deferred().rejectWith( this, [ jqXHR, statusText, parsed ] );
- }).promise( jqXHR );
- jqXHR.success = jqXHR.done;
- jqXHR.error = jqXHR.fail;
- }
- });
http://lithostech.com/2011/04/jquery-deferreds-and-the-jquery-promise-method/
Advertisements
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback