我在将站点部分划分为不同文件时遇到问题,因此编辑起来更容易,但我遇到了一些问题..该站点无法正常工作..
这是有效的原始部分:
<?php if($_SERVER["HTTP_X_PJAX"]): ?>
<div id="main">first change</div>
<?php else: ?>
<html>
<head>
<script src="http://pjax.heroku.com/jquery.js"></script>
<script src="http://pjax.heroku.com/jquery.cookie.js"></script>
<script src="http://pjax.heroku.com/jquery.pjax.js"></script>
<script type="text/javascript">
$(function() { $('a').pjax('#main');
$('#main').bind('pjax:start', function(){$('#main').animate({ height: 'hide', opacity: 'hide' }, 'fast')})
.bind('pjax:end', function(){$('#main').animate({ height: 'show', opacity: 'show' }, 'slow')}); });
</script>
</head>
<body>
<?php
$header = "this is first part
<br/> <a href='test2.php' data-pjax='main'>GO</a>";
$date = date("Y-m-d H:i:s");
$footer = "this is first part";
echo "$header<br/>$date<br /><div id='main'>first page</div><br />$footer";
?>
</body>
</html>
<?php endif; ?>
这是我现在拥有的,但它不起作用:
<?php $body = "<div id='main'>first page</div><br /><a href='pjax2.php' data-pjax='main'>GO BACK</a>"; ?>
<?php if($_SERVER["HTTP_X_PJAX"]): ?>
<?php echo "$body";?>
<?php else: ?><?php include "header.php";?>
<?php echo "$body"; ?><?php include "footer.php" ;>
<?php endif; ?>
Header.php 是这样的:
<html>
<head>
<script src="http://pjax.heroku.com/jquery.js"></script>
<script src="http://pjax.heroku.com/jquery.cookie.js"></script>
<script src="http://pjax.heroku.com/jquery.pjax.js"></script>
<script type="text/javascript">
$(function() { $('a').pjax('#main');
$('#main').bind('pjax:start', function(){$('#main').animate({ height: 'hide', opacity: 'hide' }, 'fast')})
.bind('pjax:end', function(){$('#main').animate({ height: 'show', opacity: 'show' }, 'slow')}); });
</script>
</head>
<body>
Footer.php 是这样的:
</body></html>