Ajax提交表单页面刷新很快的解决方法

注:使用ajax 提交表单时 type类型最好不用submit 用button合适

<form>
   <div 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>

相关推荐