Notepad:Ajax

From Amar
Revision as of 04:49, 20 February 2007 by 192.168.1.101 (talk) (AJAX Howto)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

From Yahoo AJAX Howto

Determine AJAX var xmlhttp = null; if (window.XMLHttpRequest) {

 xmlhttp = new XMLHttpRequest();
 if ( typeof xmlhttp.overrideMimeType != 'undefined') {
   xmlhttp.overrideMimeType('text/xml');
 }

} else if (window.ActiveXObject) {

 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

} else {

 alert('Perhaps your browser does not support xmlhttprequests?');

}

Send request xmlhttp.open('GET', url, true); xmlhttp.send(null);

Define Callback xmlhttp.onreadystatechange = function() {

 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   // do something with the results
 } else {
   // wait for the call to complete
 }