bluebutterflyofyourmind Posted October 2, 2008 Share Posted October 2, 2008 Hey there. so i've tried my hardest to figure out this problem on my own but haven't been able to. I beg anyone with info for help. I have two galleries of photos, and a drop down beside each photo allowing users to move a photo between galleries. When the drop down is changed submitGalChange() is called //submit gallery change for a given image function submitGalChange(imageID,dropDownID,oldGal){ dropDown = document.getElementById(dropDownID); targetGallery=dropDown.value; //call movephoto httpObject = new getHTTPObject(); if(httpObject != null){ httpObject.open("GET","movePhoto.php?newGallery="+targetGallery+"&imageID="+imageID, true); httpObject.send(null); httpObject.onreadystatechange = function(){updateGallery(targetGallery,oldGal);} } } after the move photo php script is called (which works fine) the function updateGallery() is called onreadyStageChange function updateGallery(newGallery,oldGallery){ if(httpObject.readyState == 4){ toggleGallery(newGallery); toggleGallery(oldGallery); } } this is just meant to check if ready state is at 4 before refreshing the desired galleries. the galleries are refreshed with toggleGallery() //toggle gallery display of a specific gallery function toggleGallery(name){ spanID = document.getElementById(name); checkboxID = name + "ID"; checkID = document.getElementById(checkboxID) httpObject = new getHTTPObject(); if(checkID.checked == true){ if(httpObject != null){ httpObject.open("GET","updateGallery.php?galleryName="+name, true); httpObject.send(null); httpObject.onreadystatechange = function(){setOutput(name);} } } else{ spanID.innerHTML = ""; } } My issue some that the second time the toggle gallery is called from updateGallery() it gets stuck at readystate 1. I've found though that if i insert alerts into the updateGallery() the script works as desired leading me to believe that this is giving the toggle gallery script time to complete before initiating the second one. how can i call this function multiple times with out running into this problem? thank you for any help!! oh and the setOutput function is this //set output span of given page function setOutput(id){ var output = document.getElementById(id); if(httpObject.readyState == 4){ output.innerHTML = httpObject.responseText; } else if(httpObject.readyState == 3){ output.innerHTML = "readystate = 3"; } else if(httpObject.readyState == 2){ output.innerHTML = "readystate = 2"; } else if(httpObject.readyState == 1){ output.innerHTML = "readystate = 1"; } else if(httpObject.readyState == 0){ output.innerHTML = "readystate = 0"; } else{ output.innerHTML = "<img src=\"images/waiting.gif\"/>"; } } once again any help greatly appreciated! Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted October 4, 2008 Share Posted October 4, 2008 When you are calling a function twice, you need two variables. httpObject for the first and then httpObjecttwo. All instances need to be: httpObject.readyState for first and httpObjecttwo.readyState, etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.