Skip to content

Instantly share code, notes, and snippets.

@johnfkneafsey
Created December 13, 2016 19:15
Show Gist options
  • Save johnfkneafsey/175015c121afcc56ec6cf91d0feeeaf0 to your computer and use it in GitHub Desktop.
Save johnfkneafsey/175015c121afcc56ec6cf91d0feeeaf0 to your computer and use it in GitHub Desktop.
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