Skip to content

Instantly share code, notes, and snippets.

@garrettwilkin
Last active December 25, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrettwilkin/7047297 to your computer and use it in GitHub Desktop.
Save garrettwilkin/7047297 to your computer and use it in GitHub Desktop.
When I click the "Fly!" button, I see the console.log output. Not so with the "Go!" button. What gives?
JS:
// Callback to populate recommendations div.
callback = function(data) {
recDiv.html("");
$.each(data.data, function(i, datum) {
var thumb = "<div class='thumb'><img src='" + datum.thumb_url_medium + "'></div>",
title = "<div class='title'>" + datum.title + "</div>"
recDiv.append("<div class='post'>"+title+thumb+"</div>");
});
};
function click(url,callback) {
console.log("clicked");
$.getJSON(url, callback);
}
function srsly() { console.log("I know, right?!");}
Buttons:
<button type="button" class="btn btn-default" onClick="click(url,callback)">Go!</button>
<button type="button" class="btn btn-default" onClick="srsly()">Fly!</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment