-1
我是AJAX的新手,我必須從PHP顯示html表格。 當我按下生成按鈕時,它應該顯示下表。 這是我在HTML文件中的代碼:在html中使用php和ajax顯示錶格
function showHint()
{
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)
{
//what codes to put here when in terms of button.
}
}
xmlhttp.open("GET","list.php", true);
xmlhttp.send();
}
</script>
</head>
<body>
<button onClick="showHint()">Generate</button>
</body>
在
xmlhttp.onreadystatechange=function()
部分
,應該是什麼說法?
這是我的PHP文件:
<?php
$a[]="James Burb";
$a[]="Melvin Chapman";
$a[]="Eric Chan";
$a[]="Aira Gomez";
echo "<table border=1>";
for($i=0; $i<count($a); $i++)
{
echo "<tr>";
echo "<td>" .$hint=$a[$i]. "</td>";
echo "</tr>";
}
echo "</table>";
?>
在此先感謝。
感謝您的幫助。有用。 – WATTS
請將答案標記爲已接受。 –