AJAX XMLHttpRequest Methods

setRequestHeader

After requested URL open, use setRequestHeader() method, to provide any optional HTTP headers for the request.

Syntax

setRequestHeader("label", "value");

Example

xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("User-Agent", "navigator.userAgent");

abort

abort() method used to abort the request.

Syntax

abort();

Example

xhr.abort();

getResponseHeader

getResponseHeader() method used to get the value of the specified HTTP header.

Syntax

getResponseHeader(header_name);

Example

var xhr_header = xhr.getResponseHeader("Content-Type");

Run it...   »


getAllResponseHeaders

getAllResponseHeaders() method used to get the all values of HTTP headers as a string.

Syntax

getAllResponseHeaders();

Example

var xhr_header = xhr.getAllResponseHeaders();

Run it...   »