I don't understand promises/deferred very much... I have something like that :
function callAjax() {
  return $.ajax({ 
     type: 'post',
     dataType: 'jsonp',
     data: {status: status, name: name},
     url: '/test',
     xhrFields: {
         withCredentials: true
     }
  });
} 
function connectAjax() {
  var msg = 'doesnt work';
  var promise = callAjax();
  promise.then(function(data, textStatus, xhr) {
    msg = 'it worked !';
  }, function(data, textStatus, xhr) {
    msg = 'it failed !';
  });
  console.log(msg); // output 'doesnt work'
}
I have tried a lot of different things (always, done, etc..) but couldn't make it work.
I use jsonp but my request isn't cross domain. I expect a 500 error from the server for my request.
 
     
    