#2
aspic2011-03-28 10:50
|
HTML代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. xml:lang="zh" lang="zh" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script type="text/javascript" src="./jquery.js"></script>
<script type="text/javascript" src="./test.js"></script>
</head>
<body>
<ul>
<li><a href="javascript:viod(0);" onclick="Navigation('home')">首页</a></li>
<li><a href="javascript:viod(0);" onclick="Navigation('anli')">案例</a></li>
</ul>
<div id="home"></div>
<div id="anli"></div>
</body>
</html>
js代码:
function Navigation(eid) {
obj = $("#"+eid);
$.ajax({
type: "POST",
url: "test.php",
data:'key='+eid,
Type: 'text',
timeout: 5000,
beforeSend: function(){
obj.html('请求中....');
},
error : function(msg){
obj.html('请求失败!');
},
success: function(msg){
obj.html(msg);
}
});
}
php处理代码:
<?php
if('home'==$_POST['key']){
print_r('<font color=red><h1>HOME</h1></font>');
}
if('anli'==$_POST['key']){
print_r('<font color=red><h1>ANLI</h1></font>');
}
?>
[local]1[/local]