Bug Tracker

Modify

Ticket #4964 (closed feature: fixed)

Opened 5 years ago

Last modified 3 years ago

Support ajax callbacks for specific status codes

Reported by: nbubna Owned by:
Priority: high Milestone: 1.5
Component: ajax Version: 1.3.2
Keywords: ajaxrewrite Cc:
Blocking: Blocked by: #7195

Description

From this thread:  http://groups.google.com/group/jquery-dev/browse_thread/thread/41be75884cc2aead

It would be nice to be able to specify callbacks to handle specific status codes. Supporting this would make extending $.ajax behavior more difficult (for things like  http://plugins.jquery.com/project/rest). So, along with this, it would be nice to support a 'ready' callback that would be called once the XHR is done and before any other callbacks are executed.

I've attached a patch to support both.

Attachments

ajaxpatch.txt Download (1017 bytes) - added by nbubna 5 years ago.
Suggested implementation
jquery4964.patch Download (1.0 KB) - added by nbubna 5 years ago.
Suggested implementation

Change History

Changed 5 years ago by nbubna

Suggested implementation

Changed 5 years ago by nbubna

Suggested implementation

comment:1 Changed 5 years ago by nbubna

Just attached an updated patch with proper tabs, proper brace style and the correct success/status handler.

comment:2 Changed 3 years ago by dmethvin

  • Status changed from new to open
  • Blocked by 7195 added
  • Milestone changed from 1.4 to 1.5

comment:3 Changed 3 years ago by rwaldron

  • Keywords ajaxrewrite added

comment:4 Changed 3 years ago by jaubourg

  • Status changed from open to closed
  • Resolution set to fixed

Fixes #4964. Adds a statusCode object together with a new statusCode method on the jXHR object (deferred behaviour). They accept a map of statusCode/callback(s). Callbacks are fired when the status code of the response correponds to the key (as a success or an error callback depending on how the request completed). Unit tests added.

Changeset: 44fc87f66ca54278e37f15885a80c2407036df57

comment:5 Changed 3 years ago by john

  • Priority changed from minor to high

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.