Last active
December 16, 2015 17:49
-
-
Save simonewebdesign/5473323 to your computer and use it in GitHub Desktop.
XMLHttpRequest - the standard way
This file contains 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
// Full docs: https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest | |
var xhr, | |
url = "menu.html", | |
method = "GET"; | |
if (XMLHttpRequest) { | |
// code for IE7+, Firefox, Chrome, Opera, Safari | |
xhr = new XMLHttpRequest(); | |
} else { | |
// code for IE5, IE6 | |
xhr = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { | |
// xhr.responseText contains the response | |
} | |
} | |
xhr.open(method, url); | |
xhr.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment