AJAX - XMLHttpRequest Object

The XMLHttpRequest object is an API that is used to transferring data between a web browser and a web server using HTTP protocol and also provides the connection between a client and server.

The object is provided by the browsers scripting languages looks like JavaScript, JScript, and other environments.

It is also known as short name “XHR”.

The concept behind the XMLHttpRequest object was originally created by Microsoft.

The XMLHttpRequest property looks like,

a)      onreadystatechange
b)     responseText
c)      responseXML
d)     status
e)      statusText
f)       readyState : the readyState can be 0, 1, 2, 3 and 4.
                                            i.            0-Your request is not initialized.
                                          ii.            1-Your request has been set up.
                                        iii.            2-Your request has been sent.
                                        iv.            3-Your request is in process.
                                          v.            4-Your request is completed.

The XMLHttpRequest method looks like,

a)      abort()
b)     setRequestHeader(label, value)
c)      getAllResponseHeaders()
d)     getResponseHeader(mame)
e)      open(method, URL, async, userName, password)
f)       send(content)

The XMLHttpRequest object Syntax looks like,
//Syntax - XMLHttpRequest Object.
var xhrp = new XMLHttpRequest();
//AJAX - The Event onreadystatechange.
var loadXhr = function() {
    var xhrp = new XMLHttpRequest();
    xhrp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("yourElementId").innerHTML = this.responseText;

    xhrp.open("GET", "ajax-info-text.txt", true);

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions