我想从userreg.php
更新另一个页面index.php
。这是我的代码:
<html>
<head>
<title> User List </title>
<link rel="stylesheet" href="css/datacss.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#img1").click(function(){
$.ajax({
type: 'POST',
url: 'userreg.php',
cache: false,
success: function(html) {
$('html').html(html);
}
});
});
});
</script>
</head>
<body>
<div id= "ajax">
<img id="img1" src="images/bg/adduser.png" onclick="ajaxFunction()">
<div class="search">
<form action="index.php" method="get">
<input type="text" id="search" name="search" placeholder="Search..." />
<input type="hidden" name="doSearch" value="1">
<input type="submit" id ="img2" name="submit" value="" /></br>
<a href="index.php"><img src="images/bg/reset.png" alt="RESET" /></a>
</form>
</div>
<table id="mytable" class="tablesorter">
<tbody>
<tr>
<th id="name" >Name</th>
<th id="email">Email</th>
<th id="dob">DOB</th>
<th id="image">Image</th>
<th>EDIT </th>
<th>DELETE</th>
</tr>
<?php
if(isset($_GET['doSearch'])) {
if($_GET['doSearch']==1) {
include'con_search.php';
}
}
else{
include('getuserdata.php');
}
?>
</tbody>
</table>
</div>
<div id="pagination">
<div id="pagiCount">
<?php
if(isset($pages))
{
if($pages > 1)
{ if($cur_page > $num_links) // for taking to page 1 //
{ $dir = "first";
echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.(1).'">'.$dir.'</a> </span>';
}
if($cur_page > 1)
{
$dir = "prev";
echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page-1).'">'.$dir.'</a> </span>';
}
for($x=$start ; $x<=$end ;$x++)
{
echo ($x == $cur_page) ? '<strong>'.$x.'</strong> ':'<a href="'.$_SERVER['PHP_SELF'].'?page='.$x.'">'.$x.'</a> ';
}
if($cur_page < $pages )
{ $dir = "next";
echo '<span id="next"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page+1).'">'.$dir.'</a> </span>';
}
if($cur_page < ($pages-$num_links) )
{ $dir = "last";
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$pages.'">'.$dir.'</a> ';
}
}
}
?>
</div>
</div>
</body>
</html>
我在Firebug中收到错误:
ReferenceError:未定义ajaxFunction
答案 0 :(得分:2)
在这一行:
from PIL import Image, ImageDraw
im = Image.new("RGB", (640, 240))
dr = ImageDraw.Draw(im)
def circle(draw, center, radius, fill):
dr.ellipse((center[0] - radius + 1, center[1] - radius + 1, center[0] + radius - 1, center[1] + radius - 1), fill=fill, outline=None)
W = 40
COLOR = (255, 255, 255)
coords = (40, 40, 600, 200)
dr.line(coords, width=W, fill=COLOR)
circle(dr, (coords[0], coords[1]), W / 2, COLOR)
circle(dr, (coords[2], coords[3]), W / 2, COLOR)
im.show()
您已指定在单击图像时应调用<img id="img1" src="images/bg/adduser.png" onclick="ajaxFunction()">
函数,但该函数不存在。由于您已使用jQuery绑定ajaxFunction
上的函数,因此您可以像这样删除该属性:
$("#img1").click
答案 1 :(得分:0)
您尚未在脚本中定义方法ajaxFunction()
,您已为id为img1
的图片提供点击事件回调(内联处理程序)。
代码中的错误:
inline
和其他内部document.ready()
。ajaxFunction()
,这是不可用的。要更正您的错误,只需从ID为inline
img1
点击处理程序