Javascript 无法使用jquery提交表单
我在使用jquery在sweetalert2中提交表单时遇到问题 以下是我的代码:Javascript 无法使用jquery提交表单,javascript,jquery,html,sweetalert2,Javascript,Jquery,Html,Sweetalert2,我在使用jquery在sweetalert2中提交表单时遇到问题 以下是我的代码: <?=form_open_multipart('controller_path','id="form_service"' , ''?> <input type="button" name="update" id="submit-operate" value="Submit To Operated" class="btn btn-success" onclick="service.submitSe
<?=form_open_multipart('controller_path','id="form_service"' , ''?>
<input type="button" name="update" id="submit-operate" value="Submit To Operated" class="btn btn-success" onclick="service.submitService()"/>
<?= form_close(); ?>
sweetalert也可以工作,当我在if(result.value)
中执行console.log时,它会显示在控制台上,但表单不会提交。有人能告诉我正确的路吗?谢谢。试试这个:
submitService = function(){
var form = $("#form_service");
swal({
title: 'Are you sure?',
text: "You will submit this service to the next phase",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Submit'
}).then((result) => {
if (result.value) {
form.submit(); //semicolon in the end
}
});
}
看看这个:访问@AnusAhmad谢谢,但它仍然不起作用。。
submitService = function(){
var form = $("#form_service");
swal({
title: 'Are you sure?',
text: "You will submit this service to the next phase",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Submit'
}).then((result) => {
if (result.value) {
form.submit(); //semicolon in the end
}
});
}