I have multiple ajax request working together, and each request based on previous request's result, if the previous request return false, the chain should stops.
Here's some code
//here is a promise chain
return this.getBand(id)
.then(this.getAlbum)
.then(this.getSong);
//ajax request for getBand
function getBand(id) {
return Ember.$.ajax({
data:{id: id},
url: urls.bandUrl,
}).then(function(result){
return result;
});
};
//ajax request for getAlbum
function getAlbum(result){
if(result.pass) {
var bandName = result.name;
return Ember.$.ajax({
//...
})
} else {
// i wanna stop the promise chain here, how to do that?
}
}
Aucun commentaire:
Enregistrer un commentaire