zoukankan      html  css  js  c++  java
  • 异步表单提交

            // 添加销售信息
            add_sale_info: function () {
                //防止两重提交
                if (this.in_syncing) {
                    return;
                }
                var current_view = this;
                this.in_syncing = true;
                //返回订单信息一览表url
                var return_url = '/order/list/';
                //返回销售添加信息编辑url
                var sale_url = '/order/add/sale/'+$('#id_pk').val()+'/info/';
                //获取前端销售信息数据
                var sale_info = { sale_price : $('#id_sale_price').val(),
                            sale_cost_price : $('#id_sale_cost_price').val(),
                            sale_bonus_price: $('#id_sale_bonus_price').val(),
                            tax_price: $('#id_tax_price').val(),
                            other_price: $('#id_other_price').val()
                            };
                //异步表单信息提交
                $.ajax({
                    type: "POST",
                    url: sale_url,
                    data: sale_info,
                    success: function(data) {
                        if (data.error_code > 0) {
                            window.alert(data.error_msg);
                        }else {
                            //请求成功后定位到订单信息一览表
                            window.location.href = return_url;
                        }
                    },
                    error: function(){
                        window.alert('与服务器通讯发生错误,请稍后重试。');
                    },
                    complete: function(){
                        //防止两重提交
                        //恢复现场
                        current_view.options.parentView.trigger('finish_ajax_sync');
                        current_view.in_syncing = false;
                  }
                });
               return false; // avoid to execute the actual submit of the form.
            },
  • 相关阅读:
    随感
    to Live On
    记Weblogic部署BUG(websocket)
    CentOS更换yum源配置
    Java-14常用类-03=String类详解
    大牛博客推荐
    java-14常用类-02=Java中的String类
    npm-02 修改NPM下载地址(转换地址与下载源)
    selenium-10 selenium原理+ide录制+文件上传+弹框处理
    测试基础介绍
  • 原文地址:https://www.cnblogs.com/blogofwyl/p/4545957.html
Copyright © 2011-2022 走看看