0

I have this form like so:

<form method="post" name="homeForm" id="homeForm" action="thank-you.php">
//...inputs here
</form>

and here is my jQuery:

$("#homeForm").on("submit", function(e){
        e.preventDefault();
        var data = $('#homeForm').serialize();
        $.ajax({url: "api.php", dataType: "json", data: data, type: "POST", success: function(result){
            console.log(result);
            window.location.href = 'thank-you.php';
        }});
    });

Is it possible to have replace the window.location.href with a post call so I can pass data to this thank you page? So basically for form does the action but only after my ajax call is successful.

What I am trying to do is on submit, make my ajax call and when its successful goto thank-you.php with the post data.

user979331
  • 11,039
  • 73
  • 223
  • 418

0 Answers0