Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过ajax发送2个联系人表单_Php_Jquery_Html_Ajax_Forms - Fatal编程技术网

Php 通过ajax发送2个联系人表单

Php 通过ajax发送2个联系人表单,php,jquery,html,ajax,forms,Php,Jquery,Html,Ajax,Forms,网站设计师正在寻求对表单更深入的理解 你好! 我在同一页上有两个类似的联系人表单,它们是通过ajax发送的 每个联系人表单本身都可以正常工作,但当我将它们放在页面上时,其中一个就停止工作了 我知道在一个页面上有两个表单存在问题,所以我给了他们不同的ID(#contactForm1,#contactForm2),这是可行的,但我确信必须有一种更聪明的方法来做到这一点 你会给我什么建议,让它以最好的方式工作 我的html如下所示: <form role="form" id="contactFo

网站设计师正在寻求对表单更深入的理解

你好!

我在同一页上有两个类似的联系人表单,它们是通过ajax发送的

每个联系人表单本身都可以正常工作,但当我将它们放在页面上时,其中一个就停止工作了

我知道在一个页面上有两个表单存在问题,所以我给了他们不同的ID(#contactForm1,#contactForm2),这是可行的,但我确信必须有一种更聪明的方法来做到这一点

你会给我什么建议,让它以最好的方式工作

我的html如下所示:

<form role="form" id="contactForm" class="contact-form" data-toggle="validator">
<section id="content">

  <!-- NAME -->
  <div class="form-group">
    <div class="controls">
      <input autocomplete="off" type="text" id="name" class="form-control" placeholder="Your Name" required data-error="Please enter your name">
      <div class="help-block with-errors"></div>
    </div>
  </div>

  <!-- SUBJECT -->
  <div class="form-group">
    <div class="controls">
      <input autocomplete="off" type="text" id="msg_subject" class="form-control" placeholder="Company Name" required data-error="Please enter your message subject">
      <div class="help-block with-errors"></div>
    </div>
  </div>

  <!-- MESSAGE -->
  <div class="form-group">
    <div class="controls">
      <textarea id="message" rows="7" placeholder="short description" class="form-control" required data-error="Write your message"></textarea>
      <div class="help-block with-errors"></div>
    </div>  
  </div>

  <!-- EMAIL -->
  <div class="form-group">
    <div class="controls">
      <input autocomplete="off" type="email" class="email form-control" id="email" placeholder="Email Adress" required data-error="Please enter your email">
      <div class="help-block with-errors"></div>
    </div>
  </div>

  <button type="submit" id="submit" class="btn btn-success"></i> SEND</button>
  <div id="msgSubmit" class="h3 text-center hidden"></div> 
  <div class="clearfix"></div>   

</section>
</form>     
使用
class=“contactForm”
代替
id=“contactForm”
并在js中:

(".contactForm").validator().on("submit", function (event) {...}
使用
class=“contactForm”
代替
id=“contactForm”
并在js中:

(".contactForm").validator().on("submit", function (event) {...}

你的代码并不反映你给表单不同的
id
值,因为正如我提到的,我认为这不是最聪明的方法。但您可以将其视为:&如果您想……在AJAX调用中,尝试添加:
async:true,
Default为false,这意味着在第一个收到成功代码之前,将不允许进一步查询。您的代码并不反映您为表单提供了不同的
id
值,因为正如我提到的,我认为这不是最明智的方式。但您可以将其视为:&如果您想……在AJAX调用中,尝试添加:
async:true,
Default为false,这意味着在第一个查询收到成功代码之前,将不允许进一步查询。