Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.