mardi 27 juin 2017

How to submit a form after event.preventdefault if there are 2 submit button

<form url="...." method="post"></form>

$('form').on("click", "#btn-approve", function(e){
        e.preventDefault();
        $.ajax({
            //checking purpose
           success: function (data) {
                if(data!=""){
                    swal({
                      .................
                    },function (isConfirm) {
                        if(isConfirm){
                            $('form').unbind('submit').submit();
                        }
                    });
                }
                else{
                    $('form').unbind('submit').submit();
                }
            },
            error: function (data) {
                console.log('Error:', data);
            }
        });
    });

I have 2 button - button reject and button approve. During click on the button approve i will call a function to do some checking and prevent form to submit first and after user confirm only submit the form. When i submit the form, it should redirect to a page but it shows a blank page. It is able to redirect to a page if without this ajax checking. Is there any solution or i am doing in wrong way?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tj4A2B
via IFTTT

Aucun commentaire:

Enregistrer un commentaire