我的网站分为4个div:页眉,导航,内容,页脚。有6个内容部分:主页,下载,技能,实践,项目和关于。
在导航中,我有一个菜单,每个部分都有链接按钮。
编辑:我想知道如何或使用什么将数据从一个php文件传递到另一个php文件而不使用表单。
使用 jQuery,你可以这样做:
.HTML:
<ul class="nav">
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
<li><a href="javascript:void(0);" name="section-filename-here">Item</a></li>
</ul>
<div id="content"></div>
在你看到name="section-filename-here"的地方,只输入文件名而不输入.php扩展名,因为这可以在jQuery中添加,如下例所示
Javascript (jQuery/aJax):
$('ul.nav li a').click(function () {
var thisSection = $(this).attr('name');
$.ajax({
url: "/path-to-sections/"+thisSection+".php",
cache: false,
success: function (data) {
$('#content').html(data);
},
error: function () {
// only put something here if you want to show an error
}
});
});