How to detect HTTP status from JavaScript

后端 未结 4 1770
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 14:59

I want to detect in a script, which could be deployed beyond my control, whether the page was delivered with a HTTP status of 200, 404 or 500 etc.

This can\'t be don

4条回答
  •  猫巷女王i
    2020-12-25 15:38

    I recently found how to do it (credits to : hunlock)

    AJAX.getAllResponseHeaders() -- returns as a string all current headers in use. AJAX.getResponseHeader("headerLabel") -- returns value of the requested header.

提交回复
热议问题