i'm having another odd issue, slightly related to timing. i would like the page to, at the end, load the new contents to the main container, then show the new page. instead, it shows the old page with the old content, then changes after that. is there any way to change this so that it is changed before it is actually shown?
Code:
$("#genInfo").click(function() {
$('#mainContent').slideUp(1000, function() {
// get the height of the main content so it can be put back properly
//$('#mainContent').height();
//show loading content
$('#loadingMain').toggle();
setTimeout(function() {
},2000);
setTimeout(function() {
// clone the div so the user can go back to the original content
var divClone = $("#mainContent").clone();
// then process the request... we will hide content until it is ready
$("#mainContent").load("functions.php?cmd=2");
// now show the content
$('#loadingMain').toggle();
$('#mainContent').slideDown(1000);
},10000);
});
});
Can you post your whole page or at least some of the html needed for this JS snippet to work? It's hard to imagine what you want and where the bug is just from this. I only see one empty timeout, but that can't be the problem, because the callback function does nothing:
setTimeout(function() {
},2000);
If you really see the old content just for a moment, then the problem is probably here:
You send a request to the server and immediately toggle that element. It usually takes some time for the request to return, so you should do that as a callback:
Bookmarks