Since I'm using this type of call often I wish to make this reusable:
function getJSON(cmd){
   $.getJSON(cmd, function(data) {
   }).done(function(data) {
       return data;
   }).fail(function() { console.log('Server failed!') });
}
I hoped to use it like this:
function susbcribe(id){
   var cmd = 'subscribe.php?='+id;
   var obj = getJSON(cmd);
   console.log(obj);    
}
But javascript runs console.log before the async json can even return anything to obj.
Just to be clear - i know i can execute code inside of .done(), but because I use this often I wish to forgo rewriting the same function over and over.
So the question is: is there a way to make js stop and wait for getJSON to finish and return something to obj ?
 
    