Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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 发布使用jquery隐藏的表单中的数据_Php_Jquery_Forms - Fatal编程技术网

Php 发布使用jquery隐藏的表单中的数据

Php 发布使用jquery隐藏的表单中的数据,php,jquery,forms,Php,Jquery,Forms,我有一个我用jquery隐藏的表单,点击后会显示出来。我想用php发布数据,但点击提交后什么也没发生。参见代码 <div class="col-12 col-sm-2 with-click-text"> <form name="contactform" method="post" action=""> <table class="click-text font-light "width="450px" > <tr> <td> &

我有一个我用jquery隐藏的表单,点击后会显示出来。我想用php发布数据,但点击提交后什么也没发生。参见代码

 <div class="col-12 col-sm-2 with-click-text">
<form name="contactform" method="post" action="">
<table class="click-text font-light "width="450px"  >
<tr>
<td>
  <label for="first_name">First Name *</label> 
 <input  type="text" name="first_name" maxlength="50" size="30">
 <label for="last_name">Last Name *</label> 
 <td valign="top">  <input  type="text" name="last_name" maxlength="50" size="30"> 
  <label for="email">Email Address *</label>
  <input  type="text" name="email" maxlength="80" size="30" required> 
  <label for="telephone">Telephone Number</label>
   <input  type="text" name="telephone" maxlength="30" size="30"> 
  <label for="comments">Comments *</label>
  <textarea  name="comments" maxlength="1000" cols="25" rows="6" required></textarea> 
   <input type="submit" name="mailit" id="submit" value="Submit"> 
  </form>
</td>
</tr>
</table>
</div>

您没有id为
submit
的元素。更新你的功能

....
$("input[type='submit']").on("click",function(){
    event.preventDefault();
    $(this).submit();

});

您可以在此处看到演示:

您尚未向
表单
元素上的
操作
属性添加值。这需要添加到处理表单的页面的URL。所谓“什么都没有发生”是指页面重新加载,但不显示消息“do something”,或者它根本没有提交?表单结束标记的位置是错误的。
什么都没有发生,我的意思是它没有发布@MarkS并没有将其保留为空@user3554382@user3554382如果表单提交到同一页面,那么,action属性的空白值是完全有效的。那么,防止默认值然后提交有什么意义呢?更不用说他的表单即使没有js也应该提交,因为这是正常的表单。诚然,他的js是错误的,但它应该与表单提交无关。我假设用户在提交之前会做一些事情。我在那里发出了警报。这就是为什么汉克斯人@HüseyinBABAL你是个天才!使用你的代码对我有效。谢谢,真的很抱歉,问题仍然存在。它不会回复任何响应,只会弹出警报窗口?我完全不知道问题现在在哪里@HüseyinBABALAre你是否将表单发布到同一页面?
....
$("input[type='submit']").on("click",function(){
    event.preventDefault();
    $(this).submit();

});