Last active
September 29, 2015 16:58
-
-
Save BriceShatzer/8f9634c5737d84dc9ea4 to your computer and use it in GitHub Desktop.
Basic AJAX Request
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 response; | |
function makeRequest (url) { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function(){ | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){ | |
response = xmlhttp.responseText; | |
} | |
} | |
xmlhttp.open("GET", url, true); | |
xmlhttp.send(); | |
} | |
makeRequest('http://jsonplaceholder.typicode.com/posts/3'); | |
console.log(response); |
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 response; | |
function makeRequest (url) { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function(){ | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){ | |
response = xmlhttp.responseText; | |
} | |
} | |
xmlhttp.open("GET", url, true); | |
xmlhttp.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment