Skip to content

Instantly share code, notes, and snippets.

@alison-mk
Last active January 10, 2016 01:25
Show Gist options
  • Save alison-mk/acd834b0ed9f97dbda7a to your computer and use it in GitHub Desktop.
Save alison-mk/acd834b0ed9f97dbda7a to your computer and use it in GitHub Desktop.
Access an Endpoint
// 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