下午所有,
我有以下代码可以正常工作,除了我需要将变量itemID
作为$_POST['deleteClientID']
发送到我的PHP脚本。现在我知道data: itemID,
是错的,但我不确定它应该是什么?
function deleteItem(item){
if (confirm("Do you wish to delete this item?")) {
//alert(item);
var parent = item.closest('.row');
var itemID = item.data('client-id');
$.ajax({
type: 'POST',
url: 'includes/delete_client.php',
data: itemID,
cache: false,
beforeSend: function() {
alert(itemID);
parent.switchClass("", "redBG", 300, "easeInOutQuad");
},
success: function() {
parent.slideUp(500,function() {
parent.remove();
});
}
});
}
return false;
}
答案 0 :(得分:4)
数据需要是一个对象,键:值
data: { deleteClientID: itemID }
答案 1 :(得分:1)
应该是:
data: { deleteClientID: itemID }
答案 2 :(得分:0)
试试这个
function deleteItem(item){
if (confirm("Do you wish to delete this item?")) {
//alert(item);
var parent = item.closest('.row');
var itemID = item.data('client-id');
$.ajax({
type: 'POST',
url: 'includes/delete_client.php',
data: {deleteClientID:itemID},
cache: false,
beforeSend: function() {
alert(itemID);
parent.switchClass("", "redBG", 300, "easeInOutQuad");
},
success: function() {
parent.slideUp(500,function() {
parent.remove();
});
}
});
}
return false;
}