function getGeoIP_smartip() { $.each(oFlag, function(ip, arrID) { $.getJSON('http://smart-ip.net/geoip-json/'+ip+'?callback=?', function(location) { $.each(arrID, function(i, id) { $('#'+id).addClass(location.countryCode); $('#'+id).attr('title', location.countryName + ' (' + location.city + ', ' + location.region + ')'); $('#'+id).css('display', 'inline-block'); }); }) .fail(function( jqxhr, textStatus, error ) { console.log( "Request Failed: " + textStatus + ", " + error ); }) .always(function() { if(++done >= total) spinner.stop(); }); }); }