Error handler does not get triggered for ajax calls
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
```
const ApplicationSource = {
withdrawApplication: {
remote (state, application) {
return $.ajax({url: 'somepath', method: 'GET'});
},
success: applicationActions.withdrawApplicationSuccess,
error: applicationActions.withdrawApplicationFailure,
}
}
```
Whenever /somepath returns a 200 it is handled by the success handler 'withdrawApplicationSuccess' but a non-200 (for ex 500 or 404), is not handled by error handler 'withdrawApplicationFailure'.
Note We are using jquery 1.11. So I am assuming the $.ajax returns a Promise.
Is there anything wrong with this?
Contributor guide
Research direction
The reported entry point is ApplicationSource.withdrawApplication.remote, which calls $.ajax and names the withdrawApplicationSuccess and withdrawApplicationFailure handlers. Start by tracing how the AJAX promise is connected to those handlers; done means a non-200 response from /somepath reaches withdrawApplicationFailure while a 200 response still reaches withdrawApplicationSuccess.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100