'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. In chrome and safari everything seems to work as expected, but in firefox it doesn't. In firefox after i hit the submit button the modal window disappears.

This is the javascript function which is triggered on submit form:

 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



Solution 1:[1]

The page might be refreshing.

Try placing event.preventDefault() at the top of your submit function.

Solution 2:[2]

Hi guys i am having the exact similar problem, data is sent to another PHP page correclty and i can print out on the other PHP page the result.. but somehow it cannot recognise success msg sent.. and throughs out the error msg..

i am using the exact similar code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cssyphus
Solution 2 0p3nS0urc3 2015