Send form without updating page [duplicate]

1

I have a registration page and I wanted my form to be sent to the page so it did not update and open% hidden%.

With script below does not let my page update, but it also does not send my form to the database:

<script>
            jQuery(document).ready(function(){
            jQuery('#meufrm').submit(function(){
            var dados = jQuery(this).serialize();

            jQuery.ajax({
            type: "POST",
            url: "vendas.php",
            data: dados,
            success: function( data )
            {                   
            if (data == "")

            }
            });

            return false;
            });
            });

This other script hides my div that works right:

<script type="text/javascript">

                function mostra() {
                    if (document.getElementById('teste').style.display == 'block'){
                        document.getElementById('teste').style.display = 'none';
                    }else {document.getElementById('teste').style.display = 'block'}
                }

            </script>
    
asked by anonymous 04.12.2015 / 18:50

1 answer

0

Create a button to give submit .

HTML

<form action="" method="get" accept-charset="utf-8">        
    <input type="text">
    <input type="text">
    <input type="text">

    <input type="button" id="enviaDados" name="" value="Envia">
</form>

JS

$(document).ready(function(){
        $("#enviaDados").on('click', function(){
            $.ajax({
                url: 'vendas.php',
                cache: false,
                type: "POST",
                success: function(){

                }
            })
        });
    }); 

If you still have a problem, it may be in your vendas.php file.

    
04.12.2015 / 18:56