Getting Hands On AJAX-New
Getting Hands On AJAX-New
AJAX
Web server
<div id="test">
<h2>Click to let AJAX change this text</h2></div>
<button type="button"
onclick="loadXMLDoc('test1.txt')">ClickMe</button>
</center>
</body>
</html>
JavaScript Code
function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); create a XMLHttpRequest
object
}
else
{// code for IE6, IE5
if IE5 or IE6 create an
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
ActiveXObject
}
Open the request
xmlhttp.open("GET",url,true);
Send request object
to
xmlhttp.send(null);
server
document.getElementById('test').innerHTML=xmlhttp.responeText;
} Update page with the
response from the server
Important Properties
Once we have sent a request to the server we are not sure about the
request completion.
Auto-Complete
Form
Voting and Rating Submission &
Validation
Lightboxes Using AJAX With
Flash