0

I am trying to load a page when it is done with certain processes. When the process is still running, it returns a 503 error code, when the page is loaded, it returns a 200 code.

I am doing this via the $.get function. However, when jQuery get's a 503 error code (and probably also with other error codes), it logs this in the console:

XHR failed loading: GET "URL".

Example:

enter image description here

How do I remove this console.log()?

Maarten Wolfsen
  • 1,625
  • 3
  • 19
  • 35
  • 3
    You can prototype your own `log()` method - however surely a better solution, not to mention more effective use of your time, is to fix the 503 error – Rory McCrossan Aug 16 '17 at 12:26
  • Return 102 PROCESSING from your server – mplungjan Aug 16 '17 at 12:29
  • console.clear() is used for clearing the messages in the console but you have to declare it on some instinct in code to clear the console – Faisal Mehmood Awan Aug 16 '17 at 12:41
  • @RoryMcCrossan Not fully explaining my code, but the 503 is supposed to be there. The function I'm making is using this code to check if the page is done with maintenance – Maarten Wolfsen Aug 16 '17 at 12:45
  • Check this answer https://stackoverflow.com/questions/11949095/how-can-i-stop-jquery-ajax-from-logging-failures-to-the-console – Chirag Maheshwari Aug 16 '17 at 12:45
  • @ChiragMaheshwari but my code isn't broken :p – Maarten Wolfsen Aug 16 '17 at 12:47
  • 1
    @MaartenWolfsen I meant that you cannot stop the chrome browser from logging 503 errors in console. So instead you should correct the server side implementation. The server should return 200 even if the process is running, with a response data indicating that the process is running. (You may run your process in background thread on the server asynchronously and return the response on the main thread.) – Chirag Maheshwari Aug 16 '17 at 12:52
  • @ChiragMaheshwari you might wanna add that as answer – Maarten Wolfsen Sep 29 '17 at 10:45

1 Answers1

1

The logging entry in chrome's console is a behaviour of chrome when any HTTP request is handled, not a problem with jQuery or ajax(XMLHttpRequest), even an or tag could cause this issue.

So you cannot stop the chrome browser from logging 503 errors in console. Instead you should correct the server side implementation. The server should return 200 even if the process is running, with a response data indicating that the process is running. (You may run your process in background thread on the server asynchronously and return the response on the main thread.)