Take the 2-minute tour ×

I'm writing a script that uses an XMLHttpRequest to search for a file defined by a relative path, by attempting to resolve that relative path against other same domain absolute paths that the script is aware of, then attempting to load the file from that resolved url. If I encounter a 404, I just try to resolve the files relative path against another absolute path, and try again. For this particular script, its perfectly fine to encounter a 404- however, my console is littered with 'Failed to load resource: the server responded with a status of 404 (Not Found) messages, and I want to suppress them.

There is no error to catch as far as I can see- error cases are handled by the xmlHttpRequest.onreadystatechange handler, and there is no window.onerror.

Is there any way to suppress these messages?


share|improve this question
I don't think you can from JavaScript. Yet there might be a (hidden) config in the developer tools –  Bergi Oct 21 '12 at 13:41
add comment

1 Answer

Wrap your code in the try{ XMLHttpRequest() }catch(err){}

Where XMLHttpRequest() is were all your code regarding the request should be, if you do this your code won't output errors. The catch(err) is used for handling errors. You must place a catch after a try always, even if you aren't going to use it.

share|improve this answer
Hi there- there is no error to catch- its precisely the problem that the try catch finally block which I have implemented around the responsible code is catching no errors- it seems that this behaviour of the web inspector cannot be controlled (or at least, this is how it looks at the moment). Thanks anyway :) –  VLostBoy Dec 27 '10 at 10:50
add comment

Your Answer


