Skip to content

Instantly share code, notes, and snippets.

@skinp
Created February 28, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skinp/1933863 to your computer and use it in GitHub Desktop.
Save skinp/1933863 to your computer and use it in GitHub Desktop.
Basic Ajax...
function ajax(url) {
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// browser doesn't support ajax. handle however you want
}
xmlhttp.onreadystatechange = triggered;
xmlhttp.open("GET", url);
xmlhttp.send(null);
}
function triggered() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById("output").innerHTML = xmlhttp.reponseText;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment