我有这样的链接。
<a href="delete.php?id=1" class="delete">Delete</a>
如果用户点击它,应该弹出确认窗口,只有在用户点击“是”后才能转到实际的url。我知道这可以防止默认行为。
function show_confirm()
{
var r=confirm("Are you sure you want to delete?");
if (r==true) { **//what to do here?!!** }
}
$('.delete').click(function(event) {
event.preventDefault();
show_confirm()
});
但是如何在确认后继续访问该链接,或向该链接发送ajax post请求呢?
<button>
而不是<a>
将防止意外打开链接,无需确认。 - Arash