var phpData = (function get_php_data() {
var php_data;
$.ajax({
url: "http://somesite/v1/api/get_php_data",
async: false,
//very important: else php_data will be returned even before we get Json from the url
dataType: 'json',
success: function (json) {
php_data = json;
}
});
return php_data;
})();
async:false = Code paused. (Other code waiting for this to finish.)
async:true = Code continued. (Nothing gets paused. Other code is not waiting.)