Why does not it work?

function request(url, data) { var deferred = $.Deferred(); $.ajax({ url: url, method: 'post', data: data, success: function(data) { deferred.resolve(data); } }); return deferred.promise(); }; 

Return value an empty ajax object (as I understand it) ...

  • console.log (data) what shows? - EatMyDust
  • 2
    @EatMyDust Object {} always :() done :() fail: () pipe :() progress: () promise: (a) state: () then :() proto : Object - bsbak
  • it is not empty, but what do you expect in it? You output it before the answer of the asynchronous function comes from the server. - Jean-Claude
  • @ Jean-Claude resolve is in success () and work as I understand it should by success and return the answer, and it returns not what I wanted - bsbak
  • and what should come back? - Jean-Claude

0