2

In my Google Chrome console I keep receiving errors when the xmlhttp status does not result in 200. For example, in certain cases I intentionally set the header of my PHP files to 500 so in javascript I can display the error and avoid anything that requires that PHP file. Since I have my own error handler for this, is there anyway to suppress the default error?

Error Example:

POST http://localhost/mama/cgi-bin/pages/Module-Install.php 500 (Internal server error) 
daxvena
  • 1,140
  • 3
  • 14
  • 30

2 Answers2

2

It seems that there is no way to supress these warnings in google chrome when handling the error yourself. For any of those who are looking for an alternate solution, embed the error code in a json object, and parse the json object client side for any errors.

daxvena
  • 1,140
  • 3
  • 14
  • 30
0

This error was sended by Server side, not browser, not js. You can not just "hide" it from console. You can handle it in onerror event:

request.onerror = function (e) {
   // do something to fix the results of server error...
};

In other words, this is a server error and it CAN break your code execution, but if you make couple steps to resume the job after a possible exception from xmlHttp class, the code will be fine.

UPD:

Just if you are pure perfectionist, and you cares about flawless environment:

In a server side you must implement the server answer without a firing any statuses except 200. It's not a super hard job. For ASP: Suppressing HTTP 500 response codes; For PHP: http://php.net/manual/en/function.http-response-code.php .

Community
  • 1
  • 1
Ruben Kazumov
  • 3,803
  • 2
  • 26
  • 39