admin管理员组文章数量:1297038
In my admin panel I'm editing user details with Jquery/Ajax by clicking on a link. It's successfully working but I want to show confirmation dialog/popup box before request is send to server. If It's yes then my function (myfunc1) will be executive otherwise it will be close. My current code is look like this.
<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);
}
});
}
How can I do this with jquery/Javascript ? Thank you for your help.
In my admin panel I'm editing user details with Jquery/Ajax by clicking on a link. It's successfully working but I want to show confirmation dialog/popup box before request is send to server. If It's yes then my function (myfunc1) will be executive otherwise it will be close. My current code is look like this.
<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);
}
});
}
How can I do this with jquery/Javascript ? Thank you for your help.
Share Improve this question edited May 3, 2014 at 5:37 Greg 2,1731 gold badge22 silver badges23 bronze badges asked May 3, 2014 at 5:33 BabuBabu 4552 gold badges14 silver badges33 bronze badges 3-
2
What is
id = id
for? – Barmar Commented May 3, 2014 at 5:34 - @Barmar It's a user id. In my php code it's looping within while() – Babu Commented May 3, 2014 at 5:36
- I mean why are you setting a variable to itself. That doesn't do anything. – Barmar Commented May 3, 2014 at 5:37
1 Answer
Reset to default 7You can call 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 );
}
});
}
}
Or you can call it in the onclick
:
onclick="if (confirm('OK to submit?')) { myfunc1('<?php echo $uid;?>'); } "
版权声明:本文标题:javascript - How do i implement a confirmation dialogbox before ajax request is send to server? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741648611a2390338.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论