0

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/

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.

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.

sbr
  • 4,735
  • 5
  • 43
  • 49
  • "*from within a webpage*" - what are you trying to do, what do you need? What problem are you trying to solve? – Bergi May 06 '15 at 22:35
  • I need to capture it using a JavaScript API. the thing is the page has some modules which make xhr request and I may not have full control to capture the xhr status for these. I was wondering I could just query / use a JS api to get a status on each xhr / resource request and take action accordingly – sbr May 06 '15 at 22:45
  • I don't think it is a duplicate, since the above question is dealing with if you have jQuery or you can define a xhr abstraction for all the network requests. I don't have that luxury here. – sbr May 07 '15 at 17:00
  • Just have a look at the second answer, man! It has nothing to do with jQuery, but does exactly what you want. (Of course, a proper abstraction would be the better way) – Bergi May 07 '15 at 17:42
  • the second answer kind of falls in the xhr abstraction way, and the thing is it is only capturing XHR requests.And it is also updating the XHR.prototype methods, which is troublesome if your JS has external components. And the biggest issue is how to capture the failed network requests made by the browser as a result of – sbr May 07 '15 at 18:18
  • Oh, I didn't get that you want to capture all network requests, not only ajax ones. But I don't think that is possible. I thought you only had problems with the xhr requests by modules that you don't control - which [that answer](http://stackoverflow.com/a/10796951/1048572) would have solved. – Bergi May 07 '15 at 18:39

1 Answers1

0

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.

Fin Dev
  • 309
  • 2
  • 8