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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -