XMLHTTP is a set of APIs that can be routed through HTTP protocols or receive XML and other data from a scripting language such as JavaScript, VbScript, JScript, and so on. The biggest use of XMLHTTP is that you can update portions of a Web page without refreshing the entire page. Almost all browsers support the XMLHttpRequest object, which is the core technology of AJAX applications. The
JS code is as follows:
The above JS Code section explains:
(1). the onReadyStateChange property of the XMLHttpRequest object that is required to perform a task when the request is sent to the server. Whenever the readyState changes, the onReadyStateChange event is triggered.
(2). the ReadyState property of the XMLHttpRequest object, which holds the XMLHttpRequest State (0~4).
- 0: Request not initialized
- 1: The server connection has been established
- 2: Request received
- 3: In Request processing
- 4: The request is complete and the response is ready
(3). Open (Method,url,async) method : Specify the type of request, URL, and whether the request is processed asynchronously.
(4). Send (content) sends a request to the server.
The above is the Ajax to create a simple instance code, I hope to help you learn, you can also create a simple example of Ajax.