我如何实现一个确认对话框/ ajax请求之前发送到服务器
How do i implement a confirmation dialog/box before ajax request is send to server?
在我的管理面板中,我使用Jquery/Ajax通过点击链接编辑用户详细信息。这是成功的工作,但我想显示确认对话框/弹出框之前的请求被发送到服务器。如果它是yes,那么我的函数(myfunc1)将是执行的,否则它将关闭。我现在的代码是这样的
<td width="70"><a href="#" onClick="myfunc1('<?php echo $uid;?>') "><input type="button" value="Edit Details" class="button" /></a></td>
function myfunc1(id) {
id = id;
$.ajax({
url: 'edit_user_details.php',
type: 'post',
data: {
'id': id
},
success: function (response) {
//$('#edit_user_result').html(response);
$('#sent_password_result' + id).html(response);
setTimeout(function () {
$('input[type=submit]').attr('disabled', false);
window.location.href = "users.php";
}, 5000);
}
});
}
我如何用jquery/Javascript做到这一点?谢谢你的帮助。
可以调用confirm()
function myfunc1(id) {
if (confirm("OK to submit?")) {
$.ajax({
url: 'edit_user_details.php',
type: 'post',
data: {'id' : id},
success: function(response) {
//$('#edit_user_result').html(response);
$('#sent_password_result'+id).html(response);
setTimeout(function() {
$('input[type=submit]').attr('disabled', false);
window.location.href = "users.php";
}, 5000 );
}
});
}
}
或者你可以在onclick
中调用它:
onclick="if (confirm('OK to submit?')) { myfunc1('<?php echo $uid;?>'); } "
相关文章:
- ajax请求的顺序总是不同的
- 从ajax请求中获取javascript对象
- Ajax请求文档就绪会导致jquery加载缓慢
- MockJax没有在JavaScript应用程序中发送对我AJAX请求的响应
- 正在传递JSONP标头's数据参数到另一个文件中的AJAX请求
- JavaScript代码未正确检查ajax请求
- node.js请求数据事件未在CORS ajax调用中触发
- jQuery Ajax GET请求工作不正常
- "日期“;AJAX请求返回的类型值未定义
- Django - 响应请求 AJAX
- 使用 jQuery 的 CORS 请求 - $.ajax()
- 如果无线电值为 ==1,则请求 ajax
- 如何处理对循环中发出的多个异步请求(AJAX 调用)的响应
- POST请求ajax jquery错误
- CasperJS don'我没有请求AJAX
- 使用这种Facebook风格的Lightbox-请求AJAX-在一个页面上覆盖多个按钮
- 400错误请求ajax post请求
- 如何在开始发送请求ajax之前延迟3秒
- 与jQuery同时请求AJAX
- 使用POST请求AJAX发送json对象