Javascript 指定要进行post调用的表单

Javascript 指定要进行post调用的表单,javascript,jquery,ajax,post,Javascript,Jquery,Ajax,Post,我目前使用html表单字段进行一次post调用。如何指定使用哪些值进行post调用?例如,我想用用户名/密码和用户名/电子邮件分别进行两次post ajax调用 $('form').submit(function() { $.ajax({ type: "Post", url: $('form').attr('action'), data: $(this).serialize(), success: function(data, status, xhr) {

我目前使用html表单字段进行一次post调用。如何指定使用哪些值进行post调用?例如,我想用用户名/密码和用户名/电子邮件分别进行两次post ajax调用

$('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>
html


或者有两个不同的表单,或者在submit事件中,检查哪些字段具有条件值和两个不同的ajax调用?你能给出示例吗?考虑第二种方法,它适合你的当前代码。如果我做2种不同的形式,你如何指定提交它的哪种形式?我认为这样更好。好吧,如果您有两个表单,只需添加一个id属性,如:并将jquery代码更改为$'formform1.submit`
<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>