Browser - XMLHttpRequest (XHR) API

> (World Wide) Web - (W3|WWW) > Web - Browser

1 - About

The XMLHttpRequest is a Aysnchronous HTTP request designed to fetch resources.

The XMLHttpRequest ​specification defines ​an API that provides ​scripted ​client functionality for transferring data between a client and a server.

The XMLHttpRequest is used heavily in AJAX programming.

See also the new Browser - Web API - Fetch function


3 - Example

function listener() {
  var data = JSON.parse(this.responseText); => (
      console.log(" "+item.price)
function error(err) {
  console.log('Fetch Error', err);
var xhRequest= new XMLHttpRequest();
xhRequest.onload = listener;
xhRequest.onerror = error;'get', '', true);

4 - Management

4.1 - See

In the Browser devtool, you can see the request.

Example with Chrome.


HTTP - Header (Fields)


X-Requested-With cannot be added to a cross domain request without the consent of the server via CORS.

5 - Documentation / Reference