Javascript jquery提交不提交
该脚本的对话框部分工作,但表单未提交Javascript jquery提交不提交,javascript,jquery,Javascript,Jquery,该脚本的对话框部分工作,但表单未提交 $(document).ready(function(){ $("form#audit_delete_form").submit(function(e) { e.preventDefault(); var $form = $(this); if ($form.find('select[name="audit_id_select"]').val() == "") { $.msgbox("Please sele
$(document).ready(function(){
$("form#audit_delete_form").submit(function(e) {
e.preventDefault();
var $form = $(this);
if ($form.find('select[name="audit_id_select"]').val() == "") {
$.msgbox("Please select an audit", {
type:"alert",
buttons: [
{type: "submit", value: "OK"}
]
});
}else{
$.msgbox("Are you sure you want to permanently delete this audit?", {
type: "confirm",
buttons : [
{type: "submit", value: "Yes"},
{type: "submit", value: "No"},
{type: "cancel", value: "Cancel"}
]
}, function(result){
if(result == 'Yes'){
$(this).submit()
}
});
}
});
});
尝试使用e.preventDefault;无论如何如果用户确认,则发出提交
$(THE_SUBMIT_BUTTON_ID).click(function(e){
e.preventDefault();
if(...){...}
else{
$.msgbox("Are you sure you want to permanently delete this audit?", {
type: "confirm",
buttons : [
{type: "submit", value: "Yes"},
{type: "submit", value: "No"},
{type: "cancel", value: "Cancel"}
]
}, function(result){
if(result == 'Yes'){
$("form#audit_delete_form").submit() // We only submit when prompted
}
我认为第一个可以很好地工作,因为您调用e.preventDefault来取消表单提交。您使用的jQuery msgbox插件是什么?听起来好像它没有阻止提交事件…我正在使用这个我会诚实地说,我相当确定这是我的逻辑不对,这是一个久经考验的插件,与我的jquery技能不同,这也是我最初的建议。虽然很奇怪,插件不会阻止…但是,是的,我说也试试。谢谢,但这不会提交表单,我会发布我的编辑code@tatty27你在按按钮吗?你必须绑定到表单上。我编辑了我的答案。@raam86我不太清楚你的意思是什么?我对JqueryYou相当陌生,必须选择表单元素。然后从那里坐车。