Created
July 18, 2019 07:32
-
-
Save ssaurel/9e2524f17e12d42a25604be903029a38 to your computer and use it in GitHub Desktop.
Random Fact Web Service Call for the Chuck Norris App in HTML5
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 randomFact() { | |
// We call the Web Service via AJAX | |
var xmlhttp = new XMLHttpRequest(); | |
var url = "https://api.chucknorris.io/jokes/random"; | |
xmlhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
var json = JSON.parse(this.responseText); | |
// We parse the JSON response | |
parseJson(json); | |
} | |
}; | |
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