Created
July 10, 2012 05:18
-
-
Save usagi/3081257 to your computer and use it in GitHub Desktop.
AJAX; simple sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <script src="test.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); } | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hello, AJAX! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment