pipe
by Akram kamal
JavaScript
function getCustomerSSNById(customerId){
return $.post("/echo/json/", {
json: JSON.stringify({firstName: "Jose", lastName: "Romaniello", ssn: "123456789"})
}).pipe(function(p){
return p.ssn;
});
}
function getPersonAddressBySSN(ssn){
return $.post("/echo/json/", {
json: JSON.stringify({
ssn: "123456789",
address: "Siempre Viva 12345, Springfield" })
}).pipe(function(p){
return p.address;
});
}
function getPersonAddressById(id){
return getCustomerSSNById(id)
.pipe(getPersonAddressBySSN);
}
getPersonAddressById(123)
.done(function(a){
alert("The address is " + a);
});