XMLHttpRequest (Level 1 and 2)
You can send requests to and receive them from a Web server using JavaScript.
XMLHttpRequest Level 2 in Mobile Applications
You can send HTTP (or HTTPS) requests to and receive responses from a Web server using JavaScript. The API is based on the HTML5 specification and the Ajax mechanism widely used in the Web environment, and it has been enhanced from the older XMLHttpRequest API.
The main features of the XMLHttpRequest Level 2 API include:
- Supporting cross-origin request sharing (CORS)
In the older XMLHttpRequest API, only same-origin resource sharing was possible. However, the XMLHttpRequest Level 2 API supports CORS.
To send a cross-origin request, you must create an XMLHttpRequest interface instance and use its open() method. Set the request URL method parameter as the cross-origin URL.
Note For the cross-origin request to work, the authority for the external domain access must be set in the server belonging to the cross-origin URL. - Supporting various response types
The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 2 API supports various response types, such as arraybuffer, blob, document, json, and text.
- Supporting form data
The newly supported FormData interface makes it possible to upload data from an entire form. For more information, see Uploading Files with Ajax.
- Receiving a more fragmented response state on the request progress status
The XMLHttpRequst Level 2 API provides more event handlers for tracking the request status and response. In addition, the onprogress event handler allows you to check the send status of a large capacity file download.
XMLHttpRequest Level 1 in Wearable Applications
You can send HTTP (or HTTPS) requests to and receive responses from a Web server using JavaScript. The API is based on the HTML5 specification and the Ajax mechanism widely used in the Web environment, and it has been enhanced from the older XMLHttpRequest API.
The main features of the XMLHttpRequest Level 1 API include:
- Supporting cross-origin request sharing (CORS)
In the older XMLHttpRequest API, only same-origin resource sharing was possible. However, the XMLHttpRequest Level 1 API supports CORS.
To send a cross-origin request, you must create an XMLHttpRequest interface instance and use its open() method. Set the request URL method parameter as the cross-origin URL.
Note For the cross-origin request to work, the authority for the external domain access must be set in the server belonging to the cross-origin URL. - Supporting various response types
The older XMLHttpRequest API only supported the text/html format for sending requests. The XMLHttpRequest Level 1 API supports various response types, such as arraybuffer, blob, document, json, and text.
- Supporting form data
The newly supported FormData interface makes it possible to upload data from an entire form. For more information, see Uploading Files with Ajax.
- Receiving a more fragmented response state on the request progress status
The XMLHttpRequst Level 1 API provides more event handlers for tracking the request status and response. In addition, the onprogress event handler allows you to check the send status of a large capacity file download.