Ajax Learning Notes (ii)

Source: Internet
Author: User

Today I saw the attributes of XMLHttpRequest:

onReadyStateChange

This event is triggered when the state is changed, and JavaScript functions are usually invoked.

Status has 5 values: 0: Uninitialized.  1: Loading.  2: Already loaded.  3: the interaction. 4: Finished.

ResponseTest

The response of the server, expressed as a string.

Responsexml

The response of the server, expressed as XML

Status

The status number of the server HTTP (200 corresponds to ok,404 is not found.) There are a lot of people who can go on

NET look for ... ................

Statustest

The status text of the server HTTP (ok,not Found. There are a lot of people can surf the internet to find

Have a look for ...............

=============================================================================

=

A simple example:

The client triggers an AJAX event.

<input type= "text" id= "email" name= "Send Mail" onblur= "Validateemail ()";>

=========================================================

Here is the Validateemail function:

var xmlHttp;
function Validataemail ()
{
var Email=document.getelemenbyid ("email");
var url= "validate?email=" + Escape (email.value);
if (window. ActiveXObject)
{
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
else if (window. XMLHttpRequest)
{
Xmlhttp=new XMLHttpRequest
}
Xmlhttp.open ("get", url);
Xmlhttp.onreadystatechange=callback;
Xmlhttp.send (NULL);
}
'***********************************************************************/
' * Function Name:callback *
' * Input Arguments: * *
' * Out Arguments: * *
'* :                                                         */
' * Description: Check the ReadyState property of the XMLHttpRequest to see the status code returned by the server. */
' * Author: * *
' * date:2006-11-30 *
'***********************************************************************/
  
function callback ()
  
{
  
if (xmlhttp.readystate==4)
  
{
  
if (xmlhttp.status==200)
  
{
  
Do what you want to do.
  
}
  
}
  
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.