python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
AJAX

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();
Example,
//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);
    xhrp.send();
}
ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
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
www.code-sample.com/. Powered by Blogger.
ASK Questions