$("form.formajax").submit(function(e) {
e.preventDefault();
var data = $(this).serialize();
var url = $(this).attr("action");
var form = $(this); // Add this line
$.post(url, data, function(data) {
$(form).children(".loginresult").html(data.loginresult);
if (data.success == 1)
{
// SUBMIT the form here with POST Values (and redirect user)
}
});
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form class="login formajax" action="abc.php" method="post">
<input type="email" >
<input type= "password">
<input type="submit">
</form>
This is my code to submit a form using Ajax. It return some values.
It also return 1
or 0
with the name data.success
If this condition gets satisfied if (data.success == 1)
I want to submit the form (redirect the user + submit post value), but how?