http status codes and their representation in the web

http status codes and their representation in the web

XML HTTP Request Properties

The XMLHttpRequest object contains six properties that represents the request in various formats, such as XML, plain text, or JSON. TheXMLHttpRequest properties help you to retrieve the information about the request and response process, such as the request and its status.

The following are the properties of XMLHttpRequest object:
  • The onereadystatechange Property
  • The readyState Property
  • The responseText Property
  • The responseXML Property
  • The Status Property
  • The StatusText Property
Now, let's discuss these Properties in detail.

The OneReadyStateChange Property

The OneReadyStateChange Property stores functions that can process the client request on the server therby, reducing the time lag and increasing the efficiency of the process. The function stored in this property acts as an event handler for an event that triggers at every state change, This is usually the event handler for the asynchronous callback, which sets or retirevs the event handler for the asynchronous requests.

The ReadyState Property

The ReadyState Property defines the current state of the XMLHttpRequest object. It specifies at what point the XMLHttpRequest object can send or receive the data. The following are the possible values indicating the various states of the XMLHttpRequest object :
  • 0 - Refers to the stage when the object has been created but not initialized. In other words, the open() method has to be called.
  • 1 - Refers to the stage when the object has been created and initialized. In other words, the send() method has not been called.
  • 2 - Refers to the stage when the send() method is called, but it is waiting for the return of the status code and the headers.
  • 3 - Refers to the stage in which some data has been received, but not all.
  • 4 - Refers to the final stage where the whole data is received from the server.

In the asynchronous callback handler, the state is checked to see whether the value of the readystate property is equal to 4, which indicates that the whole data is received from the server. Once the data has been received completely, the other properties and methods can be used to get back from the response to the request.

The responesText Property

The responseText Property of XMLHttpRequest object the response in the form of a string. If the readyState value is 0,1,2, then the responseText property contains an empty string. However, when the readyState value change to 3 (receiving), the responseText property contains the incomplete response received by the client. Finally, when the readyState value changes to 4(loaded), the responseText property contains the complete response received by the client.


The responseXML Property

The responseXML property of XMLHttpRequest object the response in an XML format. This property returns an XML document object, which can be examined and parsed by using W3C Document Object Model (DOM) node tree methods and properties. The responseXML property returns the XML response when the complete HTTP response has been received (when the readyState value is 4). The value of responseXML property is an object of type Document interface, and represents the parsed document. If the document cannot be parsed, the responseXML value is null.


The statusText Propert

The StatusText Property is used to retriev the HTTP status of a request. This property is read-only and contains an empty string as its default value. The statusText property provides the textual description of the value supplied by the statue property. This property is available only when the readyState value is 3 or 4. If you try to access the statusText property for other readyState values, an exception arises.



The Status Property

The status property represents the HTTP status code, which is of short datatype. It is available only when the readyState value is either 3 or 4. If the value of the status property is accessed when the value of the readyState property is less than 3, then an exception arises. However, if the value of the 3 or equal to 4 then, the value of the status property is retrieved successfully. This value contains an HTTP status code, which represents the status of the response.


HTTP Status Code HTTP Status Representation
100 Representes the text Continue
101 Representes the text Switching Protocols
200 Representes the text OK
201 Representes the text Created
202 Representes the text Accepted
203 Representes the text Non-Authoritative Information
204 Representes the text No Content
206 Representes the text Partial Content
300 Representes the text Multiple Choice
301 Representes the text Move Permanently
302 Representes the text Found
303 Representes the text See Other
304 Representes the text Not Modified
305 Representes the text Use Proxy
306 Representes the text Unused
307 Representes the text Temporary Redirected
400 Representes the text Bad Request
402 Representes the text Payment Required
403 Representes the text Forbidden
404 Representes the text Not Found
405 Representes the text Method Not Allowed
406 Representes the text Not Acceptable
407 Representes the text Proxy Authentication Required
408 Representes the text Request Timeout
409 Representes the text Conflict
410 Representes the text Gone
411 Representes the text Length Required
412 Representes the text Precondition Failed
413 Representes the text Entity Too Large
414 Representes the text Request URI Too Large
415 Representes the text Unsupported Media Type
416 Representes the text Request Range Not Satisfiable
417 Representes the text Expectation Failed
500 Representes the text Internal Server ERROR
501 Representes the text Not Implemented
502 Representes the text Bad Gateway
503 Representes the text Service Unavailable
504 Representes the text Gateway Timeout
505 Representes the text HTTP Version Not Supported

Post a Comment

If you have any query / questions, feel free to contact us.

Previous Post Next Post