AJAX is called "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML). It is a Web page development technology used to create interactive web applications.
Asynchronous indicates Asynchronous,
In addition, both javascript and xml are nouns.
Javascript is used as the client script.
The main idea of ajax is to use the XMLHttpRequest object to asynchronously (synchronously) request the server script. After the server receives the request, it returns it to the client through response. write.
Var xmlHttp; // global
// Create an XML request
Function createXMLHttpRequest (){
Try {xmlHttp = new ActiveXObject ("Msxml2.XMLHTTP");} catch (_ e) {try {xmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");} catch (_ E) {}} if (! XmlHttp & typeof XMLHttpRequest! = ''Undefined') {try {xmlHttp = new XMLHttpRequest ();} catch (e) {xmlHttp = false ;}}}
The client uses xmlHttp. responseText
Or xmlHttp. respnseXML
To obtain the value returned by the server. Therefore, the server returns a common string and formatted xml text string)
Here we will mainly introduce the returned xml:
Declare one point: Both xml and plain text are transmitted as strings !!!!!! However, during receiving at both ends, the formatted xml characters must be deserialized (converting strings into xml objects)
The following is an example: the XMLHttpRequest object has been declared.
Var obj = null; function initXDom (xmlText) {if (typeof (DOMParser )! = "Undefined") {// Gecko, Mozilla, Firefox var parser = new DOMParser (); obj = parser. parseFromString (xmlText, "text/xml ");}