Five steps to use the XMLHTTPRequest object:
1. Create an XMLHTTPRequest object
2. register the callback function
3. set parameters for interaction with the server (open method)
4. send data to the server and start interaction (send method)
5. Check whether the interaction ends and whether the response data is received successfully in the callback function.
Next, we will explain the problems that may occur in each step and the precautions:
First, because of the browser version and XMLHttpRequest support, there are some differences when creating xmlhttpreque objects.
In the IE family, versions earlier than IE7 regard XMLHttpRequest as an ActiveX control. To create an XMLHTTPRequest object, use the following statement:
XMLHTTP = newactivexobject (name)
The names here are also different, because the names of the controls they define are different for different ie versions. Microsoft. XMLHTTP is the most commonly used one.
Of course, there are some "amazing": "msxml2.xmlhttp. 6.0 "," msxml2.xmlhttp. 5.0 "," msxml2.xmlhttp. 4.0 "," msxml2.xmlhttp. 3.0 "," msxml2.xmlhttp ", these are only for some very old versions of browsers.
When registering a callback function, you must note that registration is not a call. What we need is the method name of the callback function, rather than the return value of the callback function.
The open method is used to set parameters for server interaction. This includes method name, server address, and Asynchronous Method.