\t \t
$("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)
\t {
// 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>
這是我的代碼提交使用Ajax的形式。它返回一些值。
它還名稱data.success
返回1
或0
如果這個條件得到滿足if (data.success == 1)
我想提交表單(將用戶重定向+提交後的值),但如何?
你有沒有試過'$(this).submit()'?或者,你在找別的東西嗎? – Nisarg
尚未@NisargShah – Toby
[This](https://stackoverflow.com/a/11543243/5894241)答案顯示如何綁定回調以形成提交完成事件,然後您可以將用戶重定向到另一個頁面。 – Nisarg