Jquery 自定义弹窗等待

(function ($) {
        $.extend({
            //弹窗蒙层
            ShowLoadDialog : function () {
                if ($("#divtipmongolia").length <= 0) {
                    var cusrtxt = $("<div id=\"divtipmongolia\" style=\"position:absolute; z-index:6666;background-color:#000000; opacity:0.6; top:0; bottom:0; right:0; left:0;\"></div>").appendTo($("body"));
                    var atexthtml = "<div style=\"margin-top:25%;text-align:center;\"> <img src=\"/Content/themes/tip/xuloading.gif\" /></div>";
                    $("#divtipmongolia").html(atexthtml);
                }
                else {
                    $("#divtipmongolia").css("display", "block");
                }
   
            },

            //关闭蒙层
            ShowLoadDialogClose: function ()
            {
                if ($("#divtipmongolia").length > 0) { $("#divtipmongolia").css("display", "none"); }
            }
        });
    }
)(jQuery)

 

Ajax Demo:

//省级区域选择
        $ParentAreaChange = function (currobject) {
            var currvals = $(currobject).val();
            $.ajax({
                type: "POST",
                url: "/AdminMgr/SysArea/GetAreaByCode",
                data: { parenccode: currvals, defalutdata: "选择市" },
                datatype: "json",
                beforeSend: function () {
                    $.ShowLoadDialog();
                },
                success: function (data) {
                    $.ShowLoadDialogClose();
                    $("#sidvlect").html('');
                    $("#xianvlect").html('');
                    if (data.length > 1) {
                        var htmlselect = "";
                        for (var index in data)
                            htmlselect += "<option value='" + data[index].c_AreaCode + "'>" + data[index].c_AreaName + "</option>";
                        htmlselect = "<select id=\"SiQuCode\" name=\"SiQuCode\" onchange='$SiQuyeAreaChange(this)'> " + htmlselect + " </select>";
                        $("#sidvlect").html(htmlselect);                    
                        $("#AreaCode").val("-1");
                    }
                    else {
                        $RecordAreaText();
                        $("#AreaCode").val(currvals);
                    }
                    console.log($("#AreaCode").val());
                },
                complete: function (XMLHttpRequest, textStatus) { },
                error: function () {

                }
            });
        }

 

posted @ 2016-05-26 18:52  jiajinhao  阅读(623)  评论(0编辑  收藏  举报