Last active
January 10, 2016 01:25
-
-
Save alison-mk/acd834b0ed9f97dbda7a to your computer and use it in GitHub Desktop.
Access an Endpoint
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
// Objective: access endpoint on server, created by Express | |
$(function() { | |
// On click of button, execute following function | |
$('button').on('click', function() { | |
// Use jQuery $.get AJAX request to pull JSON feed | |
$.get('/dinosaurs', function(data) { | |
// Write random dinosaur into page within a <span> tag | |
$('span').html(data.dinosaur); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment