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

Ajax submission form page refreshes quickly with examples

小云云
Release: 2023-03-19 11:50:01
Original
1772 people have browsed it

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>
Copy after login

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!

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