Quantcast
Viewing latest article 24
Browse Latest Browse All 44

Answer by Mahfuzur Rahman for How do I return the response from an asynchronous call?

Use a callback() function inside the foo() success.Try it in this way. It is simple and easy to understand.

var lat = "";var lon = "";function callback(data) {    lat = data.lat;    lon = data.lon;}function getLoc() {    var url = "http://ip-api.com/json"    $.getJSON(url, function(data) {        callback(data);    });}getLoc();

Viewing latest article 24
Browse Latest Browse All 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>