【发布时间】:2014-11-20 01:14:30
【问题描述】:
在表中(包含来自我的数据库的记录、客户凭据)我对每一行都有一个 删除 按钮。
我希望如果我点击删除按钮,这将删除该行,将记录的 ID 传递给 deletecustomer.php
当我单击删除按钮时,我有一个 ajax 模式询问您是否要确认操作。
问题是,如果我单击 CONFIRM(在模式中),我的模式将进入 delete-utente.php (其中我有删除行的查询)但 ID 没有传递。
在 delete-utente.php 中,如果查询正常(删除完成),我会收到一条消息,如果无法完成删除,我会收到另一条消息。
单击确认后,我总是有 OK 消息,但客户尚未被删除。
我想问题不在于 deletecustomer.php 因为如果我使用简单的 javascript 警报,查询就可以了,并且我成功传递了标识符,但是使用 ajax 模式,标识符没有传递。
我是第一次使用ajax,所以我认为是ajax代码的问题。
我的主页中表格的代码 (newcustomer.php)
<table class="simple-table responsive-table" method="POST" id="customer-list">
//code thead
//rows rows..
<?php echo '<button type="input" class="button icon-trash with-tooltip confirm" onclick="openConfirm()" href="deletecustomer.php?customerid='.$idcustomer.'" title="Delete"></button>'; ?>
//....
</table>
ajax 模式
function openConfirm()
{
$.modal.confirm('Sicuri di voler cancellare il cliente?', function()
{
window.location.href = "deletecustomer.php"; //the php file where I have the delete query
}, function()
{
window.location.href = "newcustomer.php";
});
};
然后我像这样在我的 deletecustomer.php 中取值
$customeridd=(int) $_GET['customerid'];
对不起,如果是愚蠢的错误或愚蠢的问题^^" 并感谢您的建议
【问题讨论】:
标签: javascript php jquery ajax button