Redirect to a page instead the action form address

29 Views Asked by At

I have been using a script to redirect my users when submitting a form but is currently causing a browser error ($ post is not a function)

Could anyone help me?

The script:

jQuery(document).ready(function(){
    jQuery('#ModalFormContato').submit(function(e){
        e.preventDefault();
        $.post($("#ModalFormContato").attr("action"), $("#ModalFormContato").serialize(), function(data) { 

            if(data.erro == "NULL") { window.location.href = "https://www.myurl.com.br/agradecimento"; }
            else { window.location.href = "https://www.myurl.com.br/erro"; }

        });
    });
});

ModalFormContato is the form ID, and the form has a action that I need to solve to send the lead while im redirecting user.

1

There are 1 best solutions below

0
Punkte On

Try by using the non-slim version of jQuery : https://cdnjs.com/libraries/jquery/