XMLHttpRequest Interview Preparation Guide

XMLHttpRequest related Frequently Asked Questions in various XHR2 job interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting
Tweet Share WhatsApp

28 XHR2 Questions and Answers:

1 :: What is responseText?

The 'responseText' property is a string version of data returned from server process.
Download XHR2 PDF Read All 28 XHR2 Questions

2 :: What is onreadystatechange?

The 'onreadystatechange' property fires at every state change event.

3 :: What is readyState?

The 'readyState' property is an object status integer. It uses the integers 0 to 4 for uninitialized, loading, loaded, interactive and complete states.

4 :: What is getAllResponseHeaders()?

The getAllResponseHeaders() method is used to return the full set of headers as a string.

5 :: What is status?

The 'status' property is for returning numeric codes from the server like error codes, etc.
Download XHR2 PDF Read All 28 XHR2 Questions

6 :: Explain setRequestHeader("label", "value")?

The setRequestHeader("label", "value") method is used to assign a label/value pair to the header to be sent with a request.

7 :: How do we pass parameters to the server?

Below are the two ways of passing data to server. The first one shows by using GET and the second by POST.

xmlHttpObj.open("GET","http://" + location.host +
"/XmlHttpExample1/WebForm1.aspx?value=123", true);
xmlHttpObj.open("POST","http://" + location.host +
"/XmlHttpExample1/WebForm1.aspx?value=123", true);

8 :: Explain the purpose of each of the HTTP request types when used with a RESTful web service?

The purpose of each of the HTTP request types when used with a RESTful web service is as follows:

► GET: Retrieves data from the server (should only retrieve data and should have no other effect).
► POST: Sends data to the server for a new entity. It is often used when uploading a file or submitting a completed web form.
► PUT: Similar to POST, but used to replace an existing entity.
► PATCH: Similar to PUT, but used to update only certain fields within an existing entity.
► DELETE: Removes data from the server.
► TRACE: Provides a means to test what a machine along the network path receives when a request is made. As such, it simply returns what was sent.
► OPTIONS: Allows a client to request information about the request methods supported by a service. The relevant response header is Allow and it simply lists the supported methods. (It can also be used to request information about the request methods supported for the server where the service resides by using a * wildcard in the URI.)
► HEAD: Same as the GET method for a resource, but returns only the response headers (i.e., with no entity-body).
► CONNECT: Primarily used to establish a network connection to a resource (usually via some proxy that can be requested to forward an HTTP request as TCP and maintain the connection). Once established, the response sends a 200 status code and a "Connection Established" message.

9 :: Can you explain Scriptmanager control in Ajax?

Scriptmanager control is the central heart of Ajax. They manage all the Ajax related objects on the page. Some of the core objectives of scriptmanager control are as follows:-

► Helps load core Ajax related script and library.
► Provides access to web services.
► ASP.NET authentication, role and profile services are loaded by scriptmanager control.
► Provided registration of server controls and behaviors.
► Enable full or partial rendering of a web page.
► Provide localization features.
In short , any Ajax enable page should have this control.

10 :: Explain Open ("method", "URL", "async", "uname", "pswd")?

Open ("method", "URL", "async", "uname", "pswd"):- This method takes a URL and other values needed for a request. You can also specify how the request is sent by GET, POST, or PUT. One of the important values is how this request will be sent asynchronously or synchronously. True means that processing is carried after the send () method, without waiting for a response. False means that processing is waits for a response before continuing.
Download XHR2 PDF Read All 28 XHR2 Questions