AJAX响应失败

When we make any AJAX request, what are the different possibilities for the response failing and how do we verify it on client-side? Is it purely based on "response.status" I am using DOJO and see one place where I am getting response from the server, but response.status is "undefined" (dojo.xhrPost response)

More importantly technically speaking from the backend/server-side, do we have to explicitly do/pass something to indicate response failure on the client-side OR is that automatically handled (assume Java in the backend)?

The whole HTTP state is based on the status of the HTTP call. The server side component should be able to send the right failure response code/HTTP Status 4xx/5xx as expected. This is irrespective of the type of server/client side component.

However, not all the failure cases needs to throw 5xx or 4xx status. For example, you may try to add a new record, if record already exists, the server can still send 200 OK response and give message stating - Record already available.

It's all with the webdeveloper's discretion :)

Have you checked the network tab of your developer tools to find the request matching the XHR that failed? It could probably tell you more.

If the status is undefined, I would guess that perhaps the XHR was aborted entirely or that there was an error even connecting, or resolving DNS, etc.