Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created October 4, 2017 01:40
Show Gist options
  • Save anthonycvella/d4fa16c3806c1f1c1f3c1e4e587abb1c to your computer and use it in GitHub Desktop.
Save anthonycvella/d4fa16c3806c1f1c1f3c1e4e587abb1c to your computer and use it in GitHub Desktop.
// NOTE: First make sure you have jquery included by placing this at the bottom of your .html file, before the </body> and </html> tags
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
// The full url path with a difficulty of "easy"
url = "https://it3049c-hangman.now.sh?difficulty=easy";
// Performs the ajax request using the GET method with a parameter in the provided url. An object is returned after using the "word"
// key to get its value
// @param url The url of the address
function getWord(url) {
$.get(url, function(data) {
return(data["word"]);
});
}
// Calling this will return and display the word based on the difficulty: easy, medium, hard.
console.log(getWord(url));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment