JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" name="q" id="search">
<ul id="suggest"></ul>
JavaScript
var combined=[];
$(document).ready(function(){
$.whenFaultTolerant = function(things) {
var remaining = Object.keys(things).length;
var outputs = {};
var dfd = $.Deferred();
$.each(things, function(key, thing) {
thing.always(function(data) {
outputs[key] = data;
--remaining || dfd.resolve(outputs);
});
});
return dfd.promise();
};
$("#search").keyup(function(e){
$(this).html("");
$.whenFaultTolerant({
suggestqueries: $.getJSON("http://suggestqueries.google.com/complete/search?q="+$("#search").val()+"&client=chrome&callback=?"),
googleapis: $.getJSON("https://www.googleapis.com/freebase/v1/search?query="+$("#search").val()+"&limit=3&encode=html&callback=?")
}).done(function(data){
console.log(data);
});
});
});