Wait for function to finish before executing the rest
- by Wurlitzer
When the user refreshes the page, defaultView() is called, which loads some UI elements. $.address.change() should execute when defaultView() has finished, but this doesn't happen all the time. $.address.change() cannot be in the success: callback, as it's used by the application to track URL changes.
defaultView();
function defaultView() {
$('#tout').fadeOut('normal', function() {
$.ajax({
url: "functions.php",
type: "GET",
data: "defaultview=true",
async: false,
success: function (response) {
$('#tout').html(response).fadeIn('normal');
}
});
});
}
$.address.change(function(hash) {
hash = hash.value;
getPage(hash);
});
I'm at a loss as to how to make $.address.change() wait for defaultView() to finish. Any help would be appreciated.