Hi,
Ich versuche seit gestern meine Seite auf AJAX zu formatieren.
Meine Index.php:
Meine script.js
Meine load_page.php
Mein Problem ist, das der PHP Code einfach im Quellcode der Seite angezeigt wird und nicht ausgeführt wird.
Ich versuche seit gestern meine Seite auf AJAX zu formatieren.
Meine Index.php:
PHP Code:
<!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" xml:lang="de" lang="de">
<head>
<title>SpaceBattle</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/main.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="wrapper">
<div id="banner"></div>
<div id="navigation">
<a href="#page1"><div id="nav">Home</div></a>
<a href="#page2"><div id="nav">Registration</div></a>
</div>
<div id="content">
<div id="register_box">
<div id="text">
</div>
</div>
<div id="login_box">
<div id="text">
<form action="login.php" method="post">
Username<br>
<input class="textbox" style="width: 100%;" type="text" name="username" id="username"></input><br><br>
Passwort<br><input class="textbox" style="width: 100%;" type="password" name="pw" id="pw"></input><br>
<br>
Server
<select style="width: 100px; color: white; background-color: black;border: none; height: 25px;">
<option value="alpha">Alpha Server</option>
</select>
<br><br>
<center><button class="button" style="width: 125px; height: 35px;" type="submit" class="button">Anmelden</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Code:
$(document).ready(function(){
checkURL();
$('#navigation a').click(function (e){
checkURL(this.hash);
});
setInterval("checkURL()",250);
});
var lasturl="";
function checkURL(hash)
{
if(!hash) hash=window.location.hash;
if(hash != lasturl)
{
lasturl=hash;
loadPage(hash);
}
}
function loadPage(url)
{
url=url.replace('#page','');
$.ajax({
type: "POST",
url: "load_page.php",
data: 'page='+url,
dataType: "php",
success: function(msg){
if(parseInt(msg)!=0)
{
$('#text').html(msg);
}
else
{
echo "FATAL ERROR";
}
}
});
}
PHP Code:
<?php
$page = (int)$_POST['page'];
if(file_exists('pages/page_'.$page.'.php'))
include('pages/page_'.$page.'.php');
else echo 'There is no such page!';
?>
Mein Problem ist, das der PHP Code einfach im Quellcode der Seite angezeigt wird und nicht ausgeführt wird.