0

I use XMLHttpRequest class to send payload data from web client to web server.

I want to handle errors such as follows...

  • REQUEST TIMEOUT (CONNECTION TIMEOUT)
  • 500, INTERNAL SERVER ERROR
  • 502, BAD GATEWAY
  • 503, SERVICE UNAVAILABLE

I do not know the obvious usage of onstatechange, onerror, ontimeout properties. I do not know if onreadystatechange alone can catch those errors.

Also, if I have to use onerror, ontimeout, I want to know what is the difference with onreadystatechange.

Dogil
  • 107
  • 1
  • 17
  • 1
    https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest – karthick Jun 07 '17 at 02:29
  • Thanks, @karthick.. onreadystatechange is supported on all browsers, and onerror is supproted on specific browsers. right? – Dogil Jun 07 '17 at 02:45

1 Answers1

0
  • onreadystatechange is the function that is triggered when the xmlhttprequest object state changes, similar to the onclick.

  • readystate is used to catch the xmlhttprequest object state , it has five values listening the server response state

  • status is the status code returned after the server responds successfully. such as 500, INTERNAL SERVER ERROR.....

Asif Raza
  • 3,435
  • 2
  • 27
  • 43
X.yuf
  • 1
  • 2