XMLHttpRequest

From Wiki @ Karl Jones dot com
Jump to: navigation, search

XMLHttpRequest (XHR) is an API available to web browser scripting languages such as JavaScript.

Description

XMLHttpRequest is used to send HTTP requests or HTTPS requests to a web server

The server response data is then received by the script, which can use the response data to update the Document Object Model.

The user does not submit the web page, nor does the browser request the entire web page.

Instead, XMLHttpRequest makes requests to the server (typically without the user's awareness), and displays the response in the browser.

This is the main principle of Ajax.

Browser support

Development versions of all major browsers support URI schemes beyond http and https, in particular, blob URLs are supported.

Various uses

Despite the name of the API, this data can be in the form of not only XML, but also JSON, HTML or plain text.

Processing the response data

The response data can evaluated and processed before displaying results. For example, if the data was formatted as JSON by the web server, it can be converted into a client-side data object as a convenience for further use.

Ajax

The Ajax web development technique used by many websites to implement responsive and dynamic web applications depends on XMLHttpRequest.

Same-origin policy

For security reasons, XMLHttpRequest requests follow the browser's same-origin policy, and will therefore only succeed if they are made to the host that served the original web page.

See also

External links