How do I extract information from a JSON object in Javascript? -


this question has answer here:

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

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -