0

I have function like this:

function GetLala() {
    var lala = $.getJSON(uriLala).done(function (data) {
        return data;
    });
    return lala;
}

Then code like this:

var data = GetLala();
console.log(data.responseJSON);

This returned me undefined. If I type this code in google chrome console - then work.

j08691
  • 204,283
  • 31
  • 260
  • 272
user3697586
  • 49
  • 1
  • 5
  • Remove the .done from GetLaLa() and put done after the call to GetLala(). Put console.log(data) inside of done(). – Mike Cheel Feb 28 '17 at 16:56
  • Awesome my friend! – user3697586 Feb 28 '17 at 16:59
  • Just so you know, your original code was returning a promise not the value (data) you were thinking. There is no property called responseJSON on the promise object returned hence the undefined you were getting. – Mike Cheel Feb 28 '17 at 17:00

0 Answers0