How can I know that a callback event has fired? I have to perform an activity after the callback event has fired, should I put the code inside the callback function or is there some other way to know when the callback has fired? Even if I put the code of the activity after the statement making the javascript request I cant be sure that the code of the activity will be executed after the callback has fired?
Share
do something at the end of the callback. like calling the function that should be invoked after the callback.
There is no other way to determine if a callback has been fired.
by “javascript request” do you mean “ajax request”. If so I would advise at doing it this way because it most probably will be fired before the callback. At most ajax requests are per definition asynchronous (Asynchronous JavaScript and XML = AJAX). And because of that the script won’t wait for the response of the request to continue with itself. That is why you should use callbacks. Callbacks make sure that some code is called after something specified had happened.