|
XMLHttpRequest ( i.e.:AJAX) objects Common events, methods, and properties
(1) event:
Ajax.onreadystatechange: Indicates that the AJAX Asynchronous object constantly listens to the server's response,
is triggered by the server program, not by the programmer
(2) Properties:
Ajax.readystate==0: Indicates that the AJAX Asynchronous object has been created, but has not yet called the Open () method
Ajax.readystate==1: Indicates that the AJAX Asynchronous object has called the Open () method, but has not yet called send () Method
ajax.readystate==2: Indicates that the AJAX Asynchronous object has called the Send () method, but the request has not yet reached the server side
Ajax.readystate==3: Indicates that the server has received a request for an AJAX Asynchronous object that is processing the response ...
ajax.readystate=="4": Indicates that the AJAX Asynchronous object has completely received the server's response information, but the received data is not necessarily correct /c12>
None of the above 5 states are the same for all browsers, but the status 4 is the same for each browser
ajax.status==200: Indicates that the AJAX Asynchronous object received a response code, if it is a number , indicating that everything is OK
Ajax.responsetext: Represents the acquisition of data from an AJAX Asynchronous Object in an HTML Vector
Ajax.responsexml: Represents the acquisition of data from an AJAX Asynchronous object in an XML vector
(3) method:
Ajax.open (Method,url, optional boolean value )
AJAX asynchronous objects prepare to send asynchronous requests
parameter one: In what way to send, commonly used GET or POST, case insensitive
parameter two: Send to where to go, commonly used Servlet or Struts2 or SPRINGMVC to receive,
This is limited to Java EE disciplines
parameter three: The default value is true, which means that AJAX objects are submitted "asynchronously" to the server
if set to false, the AJAX object is submitted to the server in a "synchronous" manner
Ajax.setrequestheader ("Content-type", "application/x-www-form-urlencoded")
represents the content in the request body, as UTF-8 is encoded in a way that is valid only for POST requests
Ajax.send (content)
AJAX Asynchronous objects really send asynchronous requests
parameter one: indicates content in the HTTP "request Body"
if it is GET mode:content = null, if force is passed to the server, the service end is not received, return null
if it is POST mode:content! = null, for example:username=jack&password=123&role=admin
|