Modify ↓
Ticket #5640 (closed feature: worksforme)
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.
