I have some asynchronous API calls. I need to do some work when the calls have finished. I have all my API calls inside a function like that :
function startProcess() {
asyncCall();
}
How do i create a callback function for the startProcess() function , so that i could run some code when the asyncCall has finished?
asked Jul 31, 2013 at 9:25
Johny Jaz
8853 gold badges14 silver badges26 bronze badges
1 Answer 1
Try the jquery $.when jQuery API
Something like this:
$.when( startProcess ).done(
function() { /* do something */ }
);
Sign up to request clarification or add additional context in comments.
3 Comments
Johny Jaz
hmm i get this error : Uncaught SyntaxError: Unexpected token (
Daniele
I edited the answer, it seems that this could be the correct sintax, let me know.
Johny Jaz
is correct but if the call is asynchronous , that doesnt mean that it will wait for that call to finish. Thats what i am trying to accomplish. Thank you very much though
Explore related questions
See similar questions with these tags.
lang-js
asyncCallitself can accept a callback or post an even somehow when it finishes.