Home >Backend Development >PHP Tutorial >Ajax submission form page refreshes quickly with examples

Ajax submission form page refreshes quickly with examples

小云云
小云云Original
2018-01-08 13:49:281751browse

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

Note: When using ajax to submit a form, it is best not to use submit but to use button instead.

<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:'/fudaMes/orderInfo/insertOrderInfo',
       data:$('#formId').serialize(),// 你的formid
       async: true,
       error: function(request) {
       new PNotify({
           title: '提交失败',
           text: '信息录入失败',
           type: 'error',
           styling: 'bootstrap3'
         });
       },
       success: function(data) {
      if(data=="success"){
          new PNotify({
             title: '提交成功',
             text: '订单信息已录入',
             type: 'success',
             styling: 'bootstrap3'
           });  
       }else{
      new PNotify({
             title: '提交失败',
             text: '信息录入失败',
             type: 'error',
             styling: 'bootstrap3'
           });
      } 
       }
     });
   }
</script>

Related recommendations:

Summary of JS page refresh methods

Several ways to refresh the page using javascript

Share the graphic and text explanation of the page refreshing without jumping after the Form is submitted

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

Statement:
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