I'm stuck figuring how set a variable value (ex. response of an ajax call) using promises.
I have for instance:
something.value = getVariable('id'); // { id : 'Adam Smith' }
where
getVariable(id) {
return $.ajax({
//...
}).done(function(response) {
//... getVariable return response
}).fail(function(response) {
//... getVariable return something_else
});
// ...
getVariable should change from promise to ajax (or any other asynchronous) response value once done().