1 回答

TA贡献1853条经验 获得超6个赞
生成 DOM 时,可以将数据属性添加到“Confirm”链接,然后可以从单击回调函数访问该属性。runConfirm
假设您要使用的id在中,这将给出:(为了清楚起见,仅显示更改的部分)$rows['rid']
多姆生成
$displaybody .= "<tr>
<td>" . $rows['lname'] . ", " . $rows['fname'] . "</td>
<td>" . $rows['subject'] . "</td>
<td>" . $rows['days'] . " " . $rows['rstime'] . " - " . $rows['retime'] . "</td>
<td>" . $rows['note'] . "</td>
<td>
<a class='runConfirm' data-id='" . $rows['rid'] . "'>Accept</a>
<a href='home.php?decline=" . $rows['rid'] . "'>Decline</a>
</td>
</tr>"
弹出窗口处理(已更新)
$('.runConfirm').click(function(event){
// get the id you want to act on
var theId = $(this).data('id');
// ask user for confirmation
alertify.confirm('Are you sure to accept this request?',
// accepted
function(){
// go to the processing page
window.location = '/accept.php?rid=' + theId;
},
// declined
function(){
alertify.error('You clicked CANCEL');
}).set('closable', false);
});
你的第三个片段将进入.accept.php
您的代码将:
使用行 ID 作为数据属性呈现表
单击“接受”时,提示用户进行确认,并将其发送到“接受.php”页面。
在服务器上运行后处理代码,最终将用户重定向到“home.php”
您可以在文档中找到有关jQuery数据的更多信息:https://api.jquery.com/data/
- 1 回答
- 0 关注
- 71 浏览
添加回答
举报