-1
這可能嗎?我現在只是做一個郵政電話。 我想用一個提交按鈕進行帶有用戶名/密碼的郵政電話和另一個帶有電子郵件/密碼的郵政電話。如果兩個都成功,重定向到另一個頁面將是最好的。兩個ajax通過一個提交按鈕打電話
Ajax調用使用jQuery:
$('form').submit(function() {
$.ajax({
type: "Post",
url: $('form').attr('action'),
data: $(this).serialize(),
success: function(data, status, xhr) {
alert("Login successful. Redirecting");
window.setTimeout(function() {
window.location.href = "3.3.3.3/login"
}, 5000);
},
error: function(data, status, xhr) {
$('form').trigger("reset");
alert("Failed to login. Please try again.");
}
});
return false;
alert("AJAX request successfully completed");
});
<html>
<head>
<title>Log In</title>
<link rel="stylesheet" href="static">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
<form action="1.1.1.1/login" method="POST">
<div class="login">
<div class="login-screen">
<div class="app-title">
<h1> Login</h1>
</div>
<input class="form-control" type="text" required name="username" placeholder="Username">
<input class="form-control" type="password" required name="password" placeholder="Password">
<input class="form-control" type="hidden" required name="eauth" value="pam">
<input class="form-control" type="text" required name="email" placeholder="email">
<p>
<input type="submit" value="Log In" />
</p>
</div>
</div>
</form>
</body>
</html>
你能給一個例子嗎? – user17651
沒有時間,所以我給你寫了一些上面的psudo代碼,你必須自己弄清楚一些事情。 :) –