XMLHttpRequest Properties
•
onreadystatechange
– Event handler that fires at each state change
– You implement your own function that handles this
•
readyState – current status of request
–
0 = uninitialized
– 1 = loading
– 2 = loaded
– 3 = interactive (some data has been returned)
• This is broken in IE right now
– 4 = complete
•
status
– HTTP Status returned from server: 200 = OK
•
responseText
– String version of data returned from server
•
responseXML
– XML DOM document of data returned
•
statusText
– Status text returned from server
•
// get an XMLHTTPRequest object
• // build a url variable, call it url
• // open a connection with the server
• /* prepare to receive response, i.e. give it to a function */• // send the request
• var myRequest = getXMLHTTPRequest( );
• function callAjax( ) // javascript code
• {
•
var url = “test.php?mike”;
•
myRequest.open( “GET”, url, true );
•
myRequest.onreadystatechange = responseAjax();
•
myRequest.send( null );
• }