What is the idiomatic way to have a callback executed when ALL of triggers are satisfied?
In particular, in the example below, what is the way to run the proceed
function when the user presses the #btn
, but no earlier than the previously launched AJAX request returns a response (or, if the users presses the button too early, wait for the AJAX response to come before firing proceed
)?
proceed = (ajaxData) -> ...
# Launch an AJAX request and display a button:
$("#btn").on 'click', -> ???
$.ajax
type: "POST"
url: ...
data: ...
success: (ajaxData) -> ???