ajax代码不刷新页面[关闭](ajax code not refresh page [closed])
<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>
有人可以超级有用,并创建一个Ajax代码,使页面不刷新表单被提交
<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 someone be super helpful and create ajax code that makes the page not refresh the form is submitted
最满意答案
不要使用<br></br>因为你不需要关闭这个标签; 改用<br /> 。 另外,我包含了一个关于如何使用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>Don't use <br></br> as you don't need to close this tag; use <br /> instead. Additionally, I included a small example on how to 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>
更多推荐
发布评论