opulis123 Posted November 11, 2011 Share Posted November 11, 2011 Hi, i am new to this site and php in general... i dont exactly know where to go for help on this one, was hoping someone here would know.. i have a site, and i use php include files to bring it together... i am trying to use an ajax script to dynamicaly change one of my divs without refreshing... i have another site where this code worked perfectly... i even copied and apsted most of it from my other site but still does not seem to work... any help would be awsome! here is the code for my page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="../../functions/javascript.js"></script> <title>Untitled Document</title> </head> <body> <div class="side-bar span-15"> <?php include("../../includes/components/sidebar.php") ?> </div> <div class="one_content span-35"> <?php include("../../includes/pages/page_one/page_one.php") ?> </div> </body> </html> Here is my ajax functions: /*********************************************** * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var loadedobjects="" var rootdomain="http://"+window.location.hostname 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) } page_request.open('GET', url, 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 is my sidebar.php: <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_one.php', 'one_content');"> <h3> Sub Page 1 </h3> </a> </div> <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_two.php', 'one_content');"> <h3> Sub Page 2 </h3> </a> </div> <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_three.php', 'one_content');"> <h3> Sub Page 3 </h3> </a> </div> <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_four.php', 'one_content');"> <h3> Sub Page 4 </h3> </a> </div> <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_five.php', 'one_content');"> <h3> Sub Page 5 </h3> </a> </div> <div class="vertnav span-15"> <a href="javascript:ajaxpage(rootdomain+'/includes/pages/page_one/page_six.php', 'one_content');"> <h3> Sub Page 6 </h3> </a> </div> The actual one_content.php is just text for now... any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/250965-php-help-ajax-rotating-include/ Share on other sites More sharing options...
opulis123 Posted November 12, 2011 Author Share Posted November 12, 2011 never mind.... figured it out... my destination div had the class as "one_content" when that should have been the ID Quote Link to comment https://forums.phpfreaks.com/topic/250965-php-help-ajax-rotating-include/#findComment-1287491 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.