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

  1. $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
  2.   if ( options.parseError ) {
  3.     jqXHR.pipe( null, function( jqXHR, statusText, errorMsg ) {
  4.         var parsed = $.parseJSON( jqXHR.responseText );
  5.         return $.Deferred().rejectWith( this, [ jqXHR, statusText, parsed ] );
  6.     }).promise( jqXHR );
  7.     jqXHR.success = jqXHR.done;
  8.     jqXHR.error = jqXHR.fail;
  9.   }
  10. });

http://lithostech.com/2011/04/jquery-deferreds-and-the-jquery-promise-method/

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: