javascript - Reloading content using php -
im programing website, use code before , works perfect when want use flash parts realoading website everytime click link.
source code:
<!doctype html> <html> <head> <title>hot king staff</title> <meta charset="utf-8"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="tagi" /> <meta name="author" content="filip jóźwiak" /> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jqub895.js"></script> </head> <body> <div id="cialo"> <?php include('header.php'); ?> <?php include('menu.php'); ?> </div> <div id="content"> <?php $id = isset($_get['id']) ? $_get['id'] : ''; switch($id) { case '': include 'content/news.php'; break; case '2': include 'content/dogs.php'; break; case '3': include 'content/training.php'; break; case '4': include 'content/links.php'; break; case '5': include 'content/contact.php'; break; default: echo 'taka strona nie istnieje'; break; } ?> </div> </body> </html>
and code of menu.php
<!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <a href="index.php"><div id="news"></div></a> <a href="index.php?id=2"><div id="dogs"></div></a> <a href="index.php?id=3"><div id="training"></div></a> <a href="index.php?id=4"><div id="links"></div></a> <a href="index.php?id=5"><div id="contact"></div></a> </body> </html>
can me that, response.
first: including ur menu, why did set:
<!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <a href="index.php"><div id="news"></div></a> <a href="index.php?id=2"><div id="dogs"></div></a> <a href="index.php?id=3"><div id="training"></div></a> <a href="index.php?id=4"><div id="links"></div></a> <a href="index.php?id=5"><div id="contact"></div></a> </body> </html>
??? if wnt include this, include menu:
<a href="index.php"><div id="news"></div></a> <a href="index.php?id=2"><div id="dogs"></div></a> <a href="index.php?id=3"><div id="training"></div></a> <a href="index.php?id=4"><div id="links"></div></a> <a href="index.php?id=5"><div id="contact"></div></a>
if want change specific part of site without refreshing completly use jquery
in main page add piece of jquery notice before can use jquery need include in website
$.ajax({ url: '/pages.php?page=dogs success: function(data) { $('#content').innerhtml(data); } });
now create pages.php
<?php if($_server['request_method'] == 'get') { if (isset($_get['page'])) { $page = $_get['page']; switch($page) { case 'dogs': echo 'dogs'; break; case 'cats': echo 'cats'; break; default: echo 'taka strona nie istnieje'; break; } } } ?>
and don't forget add content div in main page so
<div id="content"></div>
Comments
Post a Comment