Home > Web Front-end > JS Tutorial > body text

Ajax submission form page refreshes quickly solution

亚连
Release: 2018-05-23 10:14:54
Original
2185 people have browsed it

This article mainly introduces the solution to quickly refresh the Ajax submission form page. Friends who need it can refer to it

Note: When using ajax to submit the form, it is best not to use submit for the type type. Use button. Appropriate

<form>
   <p class="col-md-9 col-sm-9 col-xs-12 col-md-offset-3">
             <input type="button" class="btn btn-info" value="重置" onclick="return resetaa()">
             <input type="button" class="btn btn-success" value="提交" onclick="return formCheck()">
</form>
 <script type="text/JavaScript">
   function formCheck(){
    $.ajax({
       type: "post",
       url:&#39;/fudaMes/orderInfo/insertOrderInfo&#39;,
       data:$(&#39;#formId&#39;).serialize(),// 你的formid
       async: true,
       error: function(request) {
       new PNotify({
           title: &#39;提交失败&#39;,
           text: &#39;信息录入失败&#39;,
           type: &#39;error&#39;,
           styling: &#39;bootstrap3&#39;
         });
       },
       success: function(data) {
      if(data=="success"){
          new PNotify({
             title: &#39;提交成功&#39;,
             text: &#39;订单信息已录入&#39;,
             type: &#39;success&#39;,
             styling: &#39;bootstrap3&#39;
           });  
       }else{
      new PNotify({
             title: &#39;提交失败&#39;,
             text: &#39;信息录入失败&#39;,
             type: &#39;error&#39;,
             styling: &#39;bootstrap3&#39;
           });
      } 
       }
     });
   }
</script>
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Two solutions for Ajax opening a new window and being intercepted by the browser

Solution WeChat returns to the previous page, The AJAX request in the page is invalid for the Get request

ajax implements asynchronous file or image upload function

The above is the detailed content of Ajax submission form page refreshes quickly solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!