Created
December 13, 2016 19:15
-
-
Save johnfkneafsey/175015c121afcc56ec6cf91d0feeeaf0 to your computer and use it in GitHub Desktop.
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 getDataFromApi(callback) { | |
var settings = { | |
url: "https://api.github.com/gists/public", | |
dataType: 'json', | |
type: 'GET', | |
success: callback | |
}; | |
$.ajax(settings); | |
} | |
// SHOW SEARCH RESULTS | |
function displayLatestGist(data) { | |
console.log(data[0].html_url); | |
} | |
// EVENT LISTENER | |
function watchSubmit() { | |
$('.js-search-form').submit(function(e) { | |
e.preventDefault(); | |
getDataFromApi(displayLatestGist); | |
}); | |
} | |
$(function(){watchSubmit();}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment