Last active
August 29, 2015 14:23
-
-
Save melloc01/1f2b42aff2e73d7f2f17 to your computer and use it in GitHub Desktop.
Como fazer uma requisição à uma API com Javascript puro
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
function XhrRequestExample { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange=function() { | |
if (xmlhttp.readyState==4 && xmlhttp.status==200){ | |
//handle success | |
} | |
} | |
xmlhttp.open("GET",'http://url-that-you-want/to-fetch'); | |
xmlhttp.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment