1

I tried something like this :

// ...
SaveSomething: function () {
    var item1 = "" //something;
    MyTools.Ajax("SaveSomething", {
        item: item1
    }).done(function (res) {
        return res.list;
    });
},
// ...

And there is the function that calls this SaveSomething function (part of a singleton)

// This is not working at all...
function SaveSomethingProcess() {
    $.when(MyObject.SaveSomething()).done(function (res) {
        console.log(res);
    });
}

I want to be able from somewhere else to call var k = SaveSomethingProcess();, wait the inner's AJAX call SaveSomething to be done and take the res object to the k variable.

Is it possible with promises or something?

Sr Julien
  • 494
  • 1
  • 8
  • 27
Giannis Grivas
  • 3,374
  • 1
  • 18
  • 38

0 Answers0