How do I extract information from a JSON object in Javascript? -
this question has answer here:
- how return response asynchronous call? 21 answers
i want city given api , display it. output on console undefined.this have far:
$.getjson("http://ip-api.com/json", function(data1){ city = data1.city; $("#city").html(city); }); console.log(city);
how can successfully?
$.getjson("http://ip-api.com/json", function(data1) { city = data1.city; $("#city").html(city); console.log(city); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="city"></div>
Comments
Post a Comment