在dbload.php
我写道:
<?php
class grid
{
function show()
{
echo"<div id = 'show'>";
if(isset( $_GET["Name"] ))
echo "done";
else
echo "Not done";
echo "</div>";
}
}
?>
并在load.php
我写道:
<!DOCTYPE html>
<?php
include "dbload.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function () {
$("a").click(function () {
$("div").load(this, function(){
alert("shod");
});
return false;
});
});
</script>
</head>
<body>
<a href="load.php?Name=mehdi"> click for load ajax</a>
<?php
$db = new grid();
$db->show();
?>
</body>
</html>
但我的加载功能不起作用。任何想法?
答案 0 :(得分:3)
您应该传递url
参数的字符串而不是对象:
$("div").load(this.href, function(){
alert("shod");
});