我正在尝试从 php 中创建的表中删除动画行。
我是 AJAX 和 JQuery 的菜鸟,我似乎看不出哪里出错了。我也尝试关注我获得代码的网站http://davidwalsh.name/animated-ajax-jquery但似乎发生的事情是当我点击删除链接时没有任何反应。
这是我的 delete.php
// connect to the database
$dbConn = odbc_connect("flamingo","","")
or die("Error opening database .... use the browsers BACK button");
if (isset($_GET['id']))
{
$id = $_GET['id'];
$result = odbc_exec($dbConn,"DELETE FROM prodList WHERE prodCode='$id'")
or die("ERROR: Cannot Delete Record!");
}
这是我的 HTML
<html>
<head>
<title>Delete a Flamingo Product from the list</title>
<script src="script/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a.delete').click(function(e) {
e.preventDefault();
var parent = $(this).parent("td").parent("tr");
$.ajax({
type: 'get',
url: 'delete.php',
data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''),
beforeSend: function() {
parent.animate({'backgroundColor':'#fb6c6c'},300);
},
success: function() {
parent.slideUp(300,function() {
parent.remove();
});
}
});
});
});
</script>
</head>
<body>
<b><font color="#000099"><font size=+2>Flamingo Product List </font></font></b>
<img SRC="pinkflamingo.gif" NOSAVE height=85 width=61>
<p>
<?php
/* script to list all the products in the prodList table
use default ODBC connection
variables
$dbConn - database connection
$sqlQuery - a query string
$dbResult - result of a, SQL query
$rows - number of rows
*/
// connect to the database
$dbConn = odbc_connect("flamingo","","")
or die("Error opening database .... use the browsers BACK button");
//Veiw record and delete
$result = odbc_exec($dbConn,"SELECT * FROM prodList ORDER BY prodCode")
or die("Error Retrieving Product Listing");
echo "<table border='1' cellpadding='10'>";
echo "<tr>
<th><font color='Red'>Code</font></th>
<th><font color='Red'>Name</font></th>
<th><font color='Red'>Description</font></th>
<th><font color='Red'>Price</font></th>
<th><font color='Red'>Delete</font></th>
</tr>";
while($row = odbc_fetch_row( $result ))
{
echo '<tr class="record" id="record-',$row['item_id'],'">';
echo '<td><b><font color="#663300">' . odbc_result ($result, "prodCode") . '</font></b></td>';
echo '<td><b><font color="#663300">' . odbc_result ($result, "prodName") . '</font></b></td>';
echo '<td><b><font color="#663300">' . odbc_result ($result, "prodDesc") . '</font></b></td>';
echo '<td><b><font color="#663300">' . odbc_result ($result, "prodPrice") . '</font></b></td>';
echo '<td><b><font color="#663300"><a href="?delete=',$row['item_id'],'" class="delete">Delete</a></font></b></td>';
echo "</tr>";
}
echo "</table>";
?>
你能看到我哪里出错了,看看我能做些什么来解决这个问题。
谢谢