/*html*/
<button class="button">b</button>
<div id="txtHint">这里是即将出现的内容</div>
/*js*/
$(function(){
$(".button").click(function(){
alert("321");
$.get("select.php",function(data){
alert(data);
$("#txtHint").html(data);
})
})
})
/*select.php*/
<?php
$con = mysql_connect("localhost","sa","sa");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("select * from Persons");
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
点击按钮后,就会显示出相应的内容。