当单击按钮时,当使用jQuery Post方法检索数据时,表单未提交


form is not submitting when click on button, when data retrieved using jquery post method

我正在使用ajax post方法检索数据,它被检索到。整个表格以分区形式显示,在表格按钮内与表单,当按钮单击表单未提交到目标文件时,其重定向到同一页面。请问有人能帮我吗?它对我很有用。代码如下:

 **jquery**
  $("#search").keyup(function(e) {
  var val=$(this).val();
   if(val=='')
   {
       //alert("empty");
       $("#resp").hide("");
   }
   else
   {
     $.post("search_db.php",{search:val},function(response){
     $("#resp").show("");
     $("#resp").html(response);
     });
   }
 });     
  **search_db.php**
  <tr align="center">
    <td><?php echo $i;  ?></td>
    <td><?php echo $rows['acc_num'];  ?></td>
    <td><?php echo $rows['cust_name'];  ?></td>
    <td><a href="tel:<?php echo $rows['phone_code'].$rows['contact']; ?>"><?php echo $rows['phone_code'].$rows['contact'];  ?></a></td>
    <td><?php echo $row_bal['bal'];  ?></td>
     <td><form action="account_statement.php" method="post"><input type="hidden" name="hide_id" value="<?php echo $rows['acc_num']; ?>" /><input type="hidden" name="hide_search" value="<?php echo $_POST['search']; ?>" /><button type="submit" class="btn btn-info">View</button></form></td>
 </tr>
 **Html**
<form action="search.php" method="post">
<div id="number"  style="padding-right:15px;">
   <div class="form-group" >
      <label class="control-label">Search</label><label id="error_search"></label>
      <input type="text" name="search" id="search" placeholder="Name or Phone or Place" required class="form-control" />
   </div>
</div>



您是否尝试过使用完整路径..?

例如:http://www.example.com/account_statement.php

简单放/之前 account_statement.php

所以你的表单操作属性类似于 action="/account_statement.php"

考虑这个表

<table id="table">
     <tr>
          <td>...1</td>
     </tr>
</table>

只需替换div ID

$("#resp").html(response);
or
//document.window.reload(); //if u want reload

你也可以使用插件(js插件)

数据表(参考此页)

https://datatables.net/examples/styling/display.html

使用 <input type="submit" /> 代替<button type="submit"> 。如果您以 html 形式使用<button>,某些浏览器将无法正常运行。