[英]Form in modal window with Ajax doesn't work in FF?
so i have a simple form in a bootstrap modal window. 所以我在引导模态窗口中有一个简单的表单。 Now with an ajax call i trigger a .php file which save the data or returns a error.
现在通过ajax调用,我会触发一个.php文件,该文件将保存数据或返回错误。 In chrome and safari everything seems to work as expected, but in firefox it doesn't.
在chrome和safari中,一切似乎都能按预期工作,但在Firefox中却不能。 In firefox after i hit the submit button the modal window disappears.
在firefox中,单击“提交”按钮后,模态窗口消失。
This is the javascript function which is triggered on submit form: 这是在提交表单时触发的javascript函数:
function submitForm(){
alert("submit data review");
var name = $('#add_owner_name').val();
var email = $('#add_owner_email').val();
$.ajax({
type:'POST',
url:'add_ajax.php',
data:'contactFrmSubmit=1&owner_email=' + email + '&owner_name=' + name,
beforeSend: function () {
$('.submitBtn').attr("disabled", "disabled");
$('.modal-body').css('opacity', '.5');
},
success:function(msg){
if (msg == 'ok'){
$('#add_owner_name').val('');
$('#add_owner_email').val('');
$('#statusMsg').html('<span style="color:green;">Thanks for your suggestion.</p>');
} else{
$('#statusMsg').html('<span style="color:red;">Some problems occurred, please try again.</span>');
}
$('.submitBtn').removeAttr("disabled");
$('.modal-body').css('opacity', '');
}
});
}
What do i overlook? 我忽略了什么? any suggestions
有什么建议么
The page might be refreshing. 该页面可能正在刷新。
Try placing event.preventDefault()
at the top of your submit function. 尝试将
event.preventDefault()
放在您的Submit函数的顶部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.