weixin_33712987 2015-09-02 08:41 采纳率: 0%
浏览 50

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)?

  • 写回答

2条回答 默认 最新

  • weixin_33733810 2015-09-02 08:49
    关注

    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 :)

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题