Notepad:Ajax: Difference between revisions

From Amar
Jump to navigationJump to search
AJAX Howto
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:


Determine AJAX
Determine AJAX
<code>
<code>
var xmlhttp = null;
var xmlhttp = null;
Line 17: Line 18:


Send request
Send request
<code>
<code>
xmlhttp.open('GET', url, true);
xmlhttp.open('GET', url, true);
Line 23: Line 25:


Define Callback
Define Callback
<code>
<code>
xmlhttp.onreadystatechange = function() {
xmlhttp.onreadystatechange = function() {
Line 31: Line 34:
   }
   }
</code>
</code>
{{Notepad}}

Latest revision as of 19:09, 20 February 2007

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
 }



← Back to Notepad



<insert>googlesearchwiki</insert> <insert>paypal</insert> <insert>analytics</insert>