我有索引页面,因为我有2个按钮"员工详细信息"和#34;学生Detalis" 当我点击"员工详细信息" ," staffDetails.php"的内容应该显示在index.php
中同样," STudent详情"还
function search1()
{ $.ajax({
Type:'GET',
url:'StaffDetails.php',
success:function(html)
{
document.getElementById("StaffDetails").innerHTML=html;
},
})
}
答案 0 :(得分:-1)
这里有一个完整的ajax函数使用,并且将来会为你提供帮助
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.7.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function search1(){
$.ajax({
type: "POST",
url:"StaffDetails.php",
beforeSend: function()
{
},
success: function(resp)
{
$("#StaffDetails").html(resp);
},
complete: function()
{
},
error: function(e)
{
alert('Error: ' + e);
}
});
}
function search2(){
$.ajax({
type: "POST",
url:"StudentDetails.php",
beforeSend: function()
{
},
success: function(resp)
{
$("#StudentDetails").html(resp);
},
complete: function()
{
},
error: function(e)
{
alert('Error: ' + e);
}
});
}
</script>
</head>
<body>
<input type="button" value="Staff Details" onclick="search1()" />
<input type="button" value="Student Details" onclick="search2()" />
<div id="StaffDetails">
</div>
<div id="StudentDetails">
</div>
</body>
这里是完整的ajax工作和测试的例子希望现在没有问题。 谢谢!