Skip to content

Instantly share code, notes, and snippets.

@usagi
Created July 10, 2012 05:18
Show Gist options
  • Select an option

  • Save usagi/3081257 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/3081257 to your computer and use it in GitHub Desktop.
AJAX; simple sample
<!DOCTYPE html>
<script src="test.js"></script>
var x = new XMLHttpRequest();
x.open('GET', 'test.txt', true);
x.onreadystatechange = function(){
if (x.readyState === 4){
var e = document.createElement('div');
e.innerHTML = x.responseText;
document.body.appendChild(e);
}
};
document.addEventListener(
'click',
function(){ x.send(); }
);
Hello, AJAX!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment