我無法刪除數據庫中的記錄,取回代碼正在工作,但刪除代碼不起作用。請幫我..謝謝提前用ajax刪除數據
代碼與AJAX獲取數據
$(document).ready(function(){
done();
});
function done(){
setTimeout(function(){
updates();
done();
}, 200);
}
function updates(){
$.getJSON("fetch.php",function(data){
$("table").empty();
$("table").append("<tr><td>Name</td><td>Date</td><td>Delete</td></tr>");
$.each(data.result, function(){
$("table").append("<tr><td>"+this['text']+"</td><td>"+this['date']+"</td><td><a id='del' href='"+this['id']+"'>Del</a></td></tr>");
});
});
}
代碼使用Ajax來刪除數據
$(function() {
$("#del").click(function(){
var element = $(this);
var id = element.attr("id");
var dataString = 'id=' + id;
if(confirm("Sure you want to delete this comment?"))
{
$.ajax({
type: "GET",
url: "del.php",
data: dataString,
success: function(){
}
});
}
return false;
});
});
PHP代碼del.php
$last_page_id = $_REQUEST['d_i_d'];
$sql = mysql_query("delete from time where id = '{$last_page_id}'");
if(!$sql){
echo mysql_error();
}else{
header('location: index.php');
}
我們需要del.php頁面的php代碼來幫助您。 – Superdrac 2014-10-20 12:07:42
'del.php'中的郵政編碼也 – 2014-10-20 12:07:45
曾經認爲這個問題可能存在於你的SQL中?作爲和/或? – 2014-10-20 12:07:58