kickoutbettman Posted May 7, 2009 Share Posted May 7, 2009 Hello all, I have a little javascript that open a div as a visible layer over the page. It works fine on my localhost, but when I upload it on my domain.com it doesn't work. Same error with both IE7 & Firefox. var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } } And here's my link <div class="box"> <a href="#" onclick="setVisible('layer1');return false" target="_self">Enter a new ADVANCED GAME</a> <br/> </div> <div id="layer1"> <div><span id="close"><a href="javascript:setVisible('layer1')" style="text-decoration: none"><strong>Hide</strong></a></span></div> <div><?php require('/golf/game/select_partners.php') ; ?></div> <div><?php require('data.php'); ?></div> </div> Anyone have an idea of what it could be ? Thank you Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } Did you mean to put a open brace after the if condition? Quote Link to comment Share on other sites More sharing options...
kickoutbettman Posted May 7, 2009 Author Share Posted May 7, 2009 Actually I guess it was a mistake, I should have put if ... { } But it doesn't change anything. I've got the same problem even if it's there or not. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Shouldn't the 2 lines in loadpage function be inside that if statement I quoted above? Quote Link to comment Share on other sites More sharing options...
kickoutbettman Posted May 7, 2009 Author Share Posted May 7, 2009 Sorry Ken, I don't understand very well. I'm very new in JS and this is a script I copied from a website. Because it's working on my localhost server (on my machine) I don't understand why it wouln't work on mydomain.com. Can you give me an idea of what the code should look like Thanks for your time Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 The function ajaxpage, where is it being called from? Quote Link to comment Share on other sites More sharing options...
kickoutbettman Posted May 7, 2009 Author Share Posted May 7, 2009 Ken I finally found my problem. I'm so stupid. The code I gave you was for another JS function. I also call a separate JS file AND I DIDN'T uploaded it to the server. It's working fine now. My bad. Thanks 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.