Trooper Posted December 31, 2006 Share Posted December 31, 2006 Hello, I have this code, but for some reson it won't replace the content of <div id="content">. I am 100% sure its not the php code. The php code simply echos some html out as a filler.[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <title>My Site</title> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="text/javascript"> function createRequestObject() { var req; if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('Your browser does not support AJAX. Get FireFox: http://www.firefox.com'); } return req; } var http = createRequestObject(); function sendRequest(action) { http.open('get', './pages.php?action='+action); http.onreadystatchange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4 && http.status == 200) { var response = http.responseText; if(response) { document.getElementById("content").innterHTML = response; } } } </script> </head><body> <div class="head"><h1>rPod</h1></div> <div class="navigation"> <a class="tab" href="javascript:sendRequest('home');">Home</a><a class="tab" href="javascript:sendRequest('about');">About</a><a class="tab" href="javascript:sendRequest('programs');">Programs</a><a class="tab" href="javascript:sendRequest('links');">Links</a> </div> <div id="content" class="content"> <p>BORK DORK CORK</p> </div> <div class="infopix"> <img src="./graphics/tableless.gif" alt="Tableless" /> <img src="./graphics/css.png" alt="W3 CSS valid" /> <img src="./graphics/html.png" alt="XHTML 1.0 valid" /> <img src="./graphics/php-power.png" alt="PHP Powered" /> <img src="./graphics/mysql.gif" alt="MySQL Powered" /> <img src="./graphics/firefox.png" alt="Best viewed in Firefox" /></div> <p class="copyright">Copyright © 2006-2007 Ryan Capote</p></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32357-wont-replace-contents-of-a/ Share on other sites More sharing options...
ober Posted December 31, 2006 Share Posted December 31, 2006 It's "innerHTML"... you have "interHTML". Quote Link to comment https://forums.phpfreaks.com/topic/32357-wont-replace-contents-of-a/#findComment-150357 Share on other sites More sharing options...
Trooper Posted December 31, 2006 Author Share Posted December 31, 2006 Thanks, but it still doesn't work. Here is my php code:[code]<?phpswitch($_GET["action"]){ case "home": echo "<p>home</p>"; break; case "about": echo "<p>about</p>"; break; case "programs": echo "<p>programs</p>"; break; case "links": echo "<p>links</p>"; break; default: echo "<p>ERROR</p>"; break;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32357-wont-replace-contents-of-a/#findComment-150528 Share on other sites More sharing options...
ober Posted January 1, 2007 Share Posted January 1, 2007 The only thing I can suggest is putting a bunch of alert()'s throughout the JS to see where it is stopping. Quote Link to comment https://forums.phpfreaks.com/topic/32357-wont-replace-contents-of-a/#findComment-150574 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.