zoukankan      html  css  js  c++  java
  • 数据提交

    1、Post提交表单

        <script>
            $("#SUB").click(function () {
                $("#submitloading").show();
                $("#SUB").attr("disabled", true);
                $.post(location.href, $('#mainForm').serialize(), function (r) {
                    if (r.status == "0") {
                        myTips(r.msg);
                        $("#SUB").attr("disabled", false);
                        $("#submitloading").hide();
                    } else {
                        myTips(r.msg, "警告", "error");
                        $("#submitloading").hide();
                        $("#SUB").attr("disabled", false);
                    }
                })
            });
        </script>
    View Code

    2、Ajax提交

            $.ajax({
                type: _type,
                dataType: _dataType,
                url: opt.url,
                data: opt.data,
                contentType: 'application/x-www-form-urlencoded',
                beforeSend: function (XHR) {
                    if (_overlay) {
                        //提交前回调方法
                        MyzhezhaoShow();
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (_overlay) {
                        //出错 
                        MyzhezhaoHide();
                    }
                    alert('服务器请求超时!');
                },
                success: function (data, textStatus) {
                    if (_overlay) {
                        MyzhezhaoHide();
                    }
                    if (opt.success != undefined) {
                        //回调
                        opt.success(data, textStatus);
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
    
                }
            });
    View Code

     3.提交对象

                $.post("/Admin/Policy/SavePolicyItem", JSON.stringify(model), function (r) {
                    if (r.error == 0) {
                        myTips(r.msg, "成功", "success");
                        $(tr).attr("id",r.ID);
                        $(tr).attr("policy_id",r.PolicyID);
                        var edit = '<a href="javascript:void(0);" class="btn btn-primary btn-sm" role="button" onclick="Edit(this);">编辑</a>';
                        $(obj).parent().prepend($(edit));
                        $(obj).remove();
                        SetDisabled(tr);
    
                    } else {
                        myTips(r.msg, "警告", "error");
                        $(obj).removeClass("lock");
                    }
                })
    View Code

     4.提交form

        function formSubmit(){
            var form = document.forms[0];
            form.action = "<%=basePath%>user/updateUser";
            form.method="post";
            form.submit();
        }
    View Code

     5.提交匿名对象

            $.ajax({
                type: "post",
                url: "/address/save",
                data: {
                    ID: id,
                    ConsigneeName: consigneeName,
                    Mobile: telephone,
                    Address: address,
                    Province: provinceVal,
                    City: cityVal,
                    District: districtVal,
                    DefaultStatus: defaultStatus
                },
                dataType: "json",
                success: function (data) {
                    isSubmit = false;
                    if ("0" == data.error) {
                        window.location.href = document.referrer;
                    } else {
                        jsprint(data.msg, "", "error");
                    }
                }
            });
    View Code
  • 相关阅读:
    【题解】NOI2014购票
    【题解】HEOI2013Eden 的新背包问题
    【题解】ZJOI2013蚂蚁寻路
    【题解】POI2014FAR-FarmCraft
    【题解】NOI2015寿司晚宴
    【题解】HNOI2018寻宝游戏
    省选算法学习-数据结构-虚树
    [HDU3516] Tree Construction [四边形不等式dp]
    [HDU3480] Division [四边形不等式dp]
    [POJ1160] Post Office [四边形不等式dp]
  • 原文地址:https://www.cnblogs.com/liandy0906/p/5739005.html
Copyright © 2011-2022 走看看