从JavaScript,任何浏览器捕获所有http请求的状态,没有jQuery?

时间:2022-02-14 16:58:38

The resource timing API gives the statistics about each loaded resource for the webpage. But it does not say anything about the ones that failed. Link to the spec: http://www.w3.org/TR/resource-timing/

资源计时API提供有关网页的每个已加载资源的统计信息。但它没有说明那些失败的事情。链接到规范:http://www.w3.org/TR/resource-timing/

Is there a way we can capture the status of each HTTP request from within a webpage, specifically the failed ones. choice of browser is not an issue.

有没有办法可以从网页中捕获每个HTTP请求的状态,特别是失败的请求。选择浏览器不是问题。

Updated: I am aware of the debugger tools in the browser that will tell the status of each network call. But I am trying to capture this via JavaScript API, programmatically.

更新:我知道浏览器中的调试器工具将告诉每个网络调用的状态。但我试图通过JavaScript API以编程方式捕获它。

1 个解决方案

#1


In Google Chrome, you can press F12 to open Developer Tools, and go to the Network tab to see all of the requests on the page. The failed ones would show up in red. You can click on each request to get more information such as what parameters were passed in the request and what response was returned, if any.

在Google Chrome中,您可以按F12打开开发人员工具,然后转到网络标签以查看该页面上的所有请求。失败者将以红色显示。您可以单击每个请求以获取更多信息,例如请求中传递的参数以及返回的响应(如果有)。

#1


In Google Chrome, you can press F12 to open Developer Tools, and go to the Network tab to see all of the requests on the page. The failed ones would show up in red. You can click on each request to get more information such as what parameters were passed in the request and what response was returned, if any.

在Google Chrome中,您可以按F12打开开发人员工具,然后转到网络标签以查看该页面上的所有请求。失败者将以红色显示。您可以单击每个请求以获取更多信息,例如请求中传递的参数以及返回的响应(如果有)。