php - ajax code not refresh page -


<form id="lets_search" action="index.php" method="post" style="width:400px;margin:0 auto;text-align:left;" role="form" target="_blank">       search here: <br> </br> <input type="text" name="search" placeholder="enter here" style="width:400px" /> <br> </br>       <input  type="submit" name="submit" value="submit"class="w3-btn w3-padding"/>        </form> 

can super helpful , create ajax code makes page not refresh form submitted

don't use <br></br> don't need close tag; use <br /> instead. additionally, included small example on how use ajax.

$("#lets_search").on('submit', function () {    $.post ("http://neil.computer/stack/ajax.php", $(this).serialize(), function (data) {      console.log(data);    })  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <form id="lets_search" action="index.php" method="post" style="width:400px;margin:0 auto;text-align:left;" role="form" target="_blank">  search here: <br /> <input type="text" name="search" placeholder="enter here" style="width:400px" /> <br />  <input  type="submit" name="submit" value="submit" class="w3-btn w3-padding"/>   </form>


Comments

Popular posts from this blog

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -