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
Post a Comment