•
The readystate property of our
XMLHTTPRequest object can have the following values:
•
0 uninitialized
• 1 loading
• 2 loaded
• 3 interactive
• 4 completed
• .. But we only want the function to execute when the readystate has value 4
• {
•
if (myRequest.readyState == 4 )
• {
•
// code here
• } // else do nothing
• }
•
{
•
if (myRequest.readyState == 4 )
•
{
•
if ( myRequest.status == 200 ) // OK
•
{
•
// code goes here (success)
•
}
•
else
•
{
•
// code an error message here
•
}
•
} // else do nothing
•
}
_ajax.status != 200 {
div=document.getElementById(‘status’) div.innerHTML = _ajax.responseText;
Save field onchange event:
_ajax = new XMLHTTPRequest(); _ajax.onreadystatechange = doResp; url = ‘./validate?field=’
Message
status=999
msg=Not a valid name
Get parameters…do some work Return something…
a text message
an XML document
an HTML snippet
a javascript method whatever you want…
Save<div id=status>Not a Valid Name