Your main problem looks to be that you are running two requests at once, and that you are using the same global variables and functions to do so. Since a request and its fulfilment are rarely instantaneous, variables and/or functions are conflicting.
Just as an example:
Code:
function openInMain(file) {
Parent = document.getElementById("main");
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="http://www.getbweb.com/vidsite/" + file;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function openInSide(file) {
Parent = document.getElementById("side");
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="http://www.getbweb.com/vidsite/" + file;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
The two pairs of colored variables in the above functions (one set red, the other green) are undeclared and in the global scope. Whichever function runs first will generally get its values overwritten by the second function before the first one has completed fetching its content. The reason why they may sometimes work together after a refresh (they wouldn't for me) is that once the browser has cached one of the requests from the server, it will load much faster, minimizing the chance that there will be a conflict.
The fact that they both:
xmlHttp.onreadystatechange=stateChanged;
means that data will further be subject to collision in that function (stateChanged).
One thing you could do is wait until one is finished and then call the other. So, in the body tag have:
Code:
<body onLoad="openInMain('mainshowcase.php');">
And at the end of stateChanged() have something like:
Code:
function stateChanged() {
if (xmlHttp.readyState==4)
{
tid=xmlHttp.responseText;
Parent.innerHTML = tid;
if(Parent.id=='main'&&document.getElementById('side').innerHTML.replace(/\s/g,'')=='')
openInSide('showcase.php');
}
}
However, there are probably better ways to overcome these issues.
Bookmarks