What is the ajax asynchronous request server like?
This article introduces what the ajax asynchronous request server is like, the content is very detailed, interested friends can refer to, hope to be helpful to you.
I used to use jquery's integrated ajax, but now let's learn JavaScript's native ajax.
The following is a simple experiment in which ajax requests a xml content on the server.
Step 1: on the server, create a new xml and name it simpleAjax.xml. Enter the contents of the file as follows: This is the content of the simpleAjax.xml from server!
Step 2: on the server, create a new html, name it simpleAjax.html, and put it in the same directory as the simpleAjax.xml you just created.
SimpleAjax var xmlHttpRequest; / / XMLHttpRequest object name function sendRequest () {/ / send http request getXMLHttpRequest () / / get an operation xmlHttpRequest.open ("GET", "simpleAjax.xml") to be performed when the state changes from a XMLHttpRequest object to xmlHttpRequest xmlHttpRequest.onreadystatechange = stateChange; / / http; / / Connect xmlHttpRequest.send (null) / / send a request to the server (empty here)} function getXMLHttpRequest () {if (window.ActiveXObject) {/ / IE class xmlHttpRequest = new ActiveXObject ("Microsoft.XMLHTTP") } else if (window.XMLHttpRequest) {/ / Chrome class xmlHttpRequest = new XMLHttpRequest () }} function stateChange () {if (xmlHttpRequest.readyState = = 4 & & xmlHttpRequest.status = = 200) {/ / request completed and status OK alert (xmlHttpRequest.responseText) / / reaction}}