Skip to content

Instantly share code, notes, and snippets.

@bhavjot
Created May 25, 2017 07:09
Show Gist options
  • Save bhavjot/faf1c126d7e9e96a06e7d6b29812cccc to your computer and use it in GitHub Desktop.
Save bhavjot/faf1c126d7e9e96a06e7d6b29812cccc to your computer and use it in GitHub Desktop.
$(document).ready(function(){
function resultCb(res){
console.log(res);
res.sort(function(a, b){
if(a < b) return -1;
if(a > b) return 1;
return 0;
});
$.each(res,function(title){
$(".news-body").append("<div>" + title+"</div");
});
}
$(".button").click(function(){
var input = $(".secret").val();
var res=[];
$.getJSON("key.json", function(keyjson) {
for(input in keyjson )
{
$.getJSON("secret_json/"+input+".json", function(json) {
res.push(json["news_title"]);
if(res.length === 75) resultCb(res);
});
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment