Bug Tracker

Modify

Ticket #5640 (closed feature: worksforme)

Opened 4 years ago

Last modified 3 years ago

Docs for $.ajax should have an example for error handling

Reported by: bjscott Owned by:
Priority: minor Milestone:
Component: docs Version:
Keywords: ajax, error, docs Cc:
Blocking: Blocked by:

Description

It isn't obvious how to get the error text returned (either in the status or the response) in $.ajax's error handler if you're not already all over XmlHttpRequest. Something like this maybe:

$.ajax({

type: "POST", url: "delete.php", data: "id=INVALID", success: function(data){

alert("Success: " + data);

}, error: function(req, status, error) {

alert("Error (status): " + req.statusText); alert("Error (response): " + req.responseText);

}

});

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Version 1.4a1 deleted
  • Resolution set to worksforme
  • Milestone 1.4 deleted

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.