从deferred.then()返回值

时间:2015-09-14 19:12:54

标签: javascript ajax dojo deferred

我想在variable x中获取ajax调用返回的值,而不进行ajax调用同步。我怎样才能做到这一点?

  foo = function() {
        var x = foo1(); 
        // var x is always undefined
  }

  foo1 = function() {
      var deferred = foo2();
      deferred.then(function(response) { return response; });
  }

  foo2 = function() {
      return dojo.xhrGet(); // ajax call
  }

0 个答案:

没有答案
相关问题