In JavaScript, is it possible to return a value from a parent function from within a jquery callback function?
function thingsLoaded() {
$("#loadingSplash").fadeOut( 1000, function() { //return thingsLoaded here });
}
I’ve read some questions on here regarding Async vs Sync for AJAX callbacks? Does the same apply for this?
Also, I do not need to pass any variables, it’s more just a timing thing to return from the thingsLoaded function once the fadeOut is completed.
EDIT: Clarification: I would like to delay returning from the thingsLoaded function, until the fadeOut callback function is complete.
Assuming I’ve understood your question correctly, (I think you want to return from
thingsLoadedin the callback, rather than actually returningthingsLoadeditself) then no.The
thingsLoadedfunction will returnundefinedbefore the callback is executed. If you have code that is dependent on the animation being finished, it has to go inside the callback. This is becausefadeOutis asynchronous.