This question has already been answered:
function f1(){ var q = $('#four').val(); $.getJSON("http://ip-api.com/json/" + q + "?callback=?", function(data) { var table_body = ""; $.each(data, function(k, v) { table_body += "<tr><td>" + k + "</td><td><b>" + v + "</b> </td></tr>"; }); $("#GeoResults").html(table_body); }); } <input id="four" type="text" onchange="f1()"> <table id="GeoResults"></table>