A.
Use JavaScript to control the show. C
Use it to asynchronously
UIHTML / CSS XMLJavaScript
request and retrieve data from data data Code –remote servers, whenever the other Bthe Ajaxprogram thinks this is a good
data (e.g. “engine”
idea (i.e. not just when the images)
user does something),
Trigger
Operation
Update
Pattern – O- Matic
• An XMLHTTPRequest object can be created on the client by javascript
• Depending on the web browser (Firefox, various versions of Internet Explorer), the code to create it is different
Ajax : XHR
•
// javascript code for all browsers
•
function getXMLHTTPRequest()
•
{
•
var request = false;
•
try
•
{
•
request = new XMLHTTPRequest( ); // Firefox
•
}
•
catch( err1 )
•
{
•
try
•
{
•
request = new ActiveXObject( “Msxml2.XMLHTTP”);
•
// some IE versions
•
catch( err2 )
•
{
•
try
•
{
•
request = new ActiveXObject( “Microsoft.XMLHTTP”);
•
// some other IE versions
•
}
•
catch( err3 )
•
{
•
request = false;
•
}
•
}
•
}
•
return request;