I can see that this matter has been discussed, but I am not making a connection with the answer given and my problem.
I am using jQuery 1.4.2 and I wish to chain two ajax calls together, passing the response for the first as an input to the second.
I have this:
ftpReport(taskID, debugMode)
.then((errorFlag) => {
return updateTask(taskID, errorFlag, debugMode);
})
.done(() => {});
The function ftpReport begins:
function ftpReport(taskID, debugMode) {
return $.ajax({
hence, I am returning this function so that it can be then-ned with the following call to updateTask
I have attempted to return a value from ftpReport (during both success and error fns) in the expectation that the returned value would be considered as errorFlag to the next step, of calling updateTask
success: function () {
return 0;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
return 1;
}
The value which appeared as errorFlag was ""
How do I correct my code so that either the 1 or the 0 reported by ftpReport will be passed to updateTask?