Created
March 9, 2012 10:59
-
-
Save ramsesoriginal/2006082 to your computer and use it in GitHub Desktop.
PJAX-PHP: Untested Code, just as a sample how one coudl theoretically implement PJAX with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$render_template=true; | |
if ($_SERVER["HTTP_X_PJAX"]) | |
{ | |
$render_template=false; | |
} | |
?> | |
<?php | |
if ($render_template) { | |
?> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Testing Pjax</title> | |
<script src="jquery.js"></script> | |
<script src="jquery.cookie.js"></script> | |
<script src="jquery.pjax.js"></script> | |
<script type="text/javascript"> | |
$(function(){ | |
$('nav a').pjax('#content') | |
}) | |
</script> | |
</head> | |
<body> | |
Date in template: <?php echo $today = date("D M j G:i:s T Y"); ?> | |
<nav> | |
<a href="index.php?content=1" >click me for other content</a> | |
<a href="index.php?content=2" >click me for even more additional content</a> | |
</nav> | |
<section id="content"> | |
<?php | |
} | |
?> | |
<?php | |
if ($_Get["content"]==1) | |
{ | |
?> | |
<h1>Content=1</h1> | |
Date in content: <?php echo $today = date("D M j G:i:s T Y"); ?> | |
<p> | |
this will be replaced by pjax with the content's of <a href="index.php?content=1">index.php?content=1</a> or <a href="index.php?content=2">index.php?content=2</a> | |
</p> | |
<?php | |
} else { | |
?> | |
<h1>Content 2=2</h1> | |
Date in content: <?php echo $today = date("D M j G:i:s T Y"); ?> | |
<p> | |
this will be replaced by pjax with the content's of <a href="index.php?content=1">index.php?content=1</a> or <a href="index.php?content=2">index.php?content=2</a> | |
</p> | |
<?php | |
} | |
?> | |
<?php | |
if ($render_template) { | |
?> | |
</section> | |
</body> | |
</html> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks