展开全部
如果你把php代码放展示页面文件上面的话62616964757a686964616fe58685e5aeb931333361326235,当执行页面时,PHP代码会被执行一遍但没有任何效果,建议把PHP代码单独一个文件,在需要的时候才调用它。
HTML CODEhtml>
click me !
function loadData()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
//Http state
{
document.getElementById("id1").innerHTML=xmlhttp.responseText;
//Assign data to id1
}
}
xmlhttp.open("GET","select.php",true);
//Use the GET method
xmlhttp.send();
}
PHP CODE《select.php》<?php
select ......
return $data;//$data是查询数据库后返回的内容