AJAX Introduction by Bhanwar Gupta - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

which brings us to Ajax

browser XMLHttpRequest() Ajax is a pattern for building JavaScript Engineapplications on the browser. AThe pattern is:
A

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),

B
B.
Use XML to send numerical or text-style data to the browser. Then use JavaScript to extract data from the XML,
C.
Use HTML and CSS for display: manipulate this using JavaScript.
C
A B C
control data display
JavaScript XML, other formats HTML and CSS 00002.jpg(e.g. images)
Ajax: Pattern

 

00002.jpgTrigger

 

00002.jpgOperation

 

00002.jpgUpdate

 

00002.jpgPattern – O- Matic

 

00002.jpg

 

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

00002.jpgAjax : XHR

 

00002.jpg

// 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;