Jump to content

Won't replace contents of a <div>


Trooper

Recommended Posts

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 &copy; 2006-2007 Ryan Capote</p>
</body>
</html>[/code]
Link to comment
Share on other sites

Thanks, but it still doesn't work. Here is my php code:

[code]
<?php
switch($_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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.