微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

zTree组织机构树涉及技术包含:zTree参数配置,ajax框架,jquery惊细控制对象,用户自定义控件,webmethod


zTree组织机构树

其中关于zTree组织机构树,涉及模块如下,采用封装自定义控件,以便多处调用自定义控件:uc_btnSelectOrganize.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uc_btnSelectOrganize.ascx.cs" Inherits="HMFW.Web.UserControl.uc_btnSelectOrganize" %>

<div>
    <div id="organizewin" iconcls="icon-save" title="组织机构选择" style="overflow: auto; display: none"></div>
    <asp:TextBox ID="txtOrganize" runat="server" class="UCSelect" ContentEditable="false" ondblclick="selectOrganizeInfo()" EnableTheming="false" title="双击选择组织机构" autocomplete="off"></asp:TextBox><img alt="选择" title="选择" src="~/Images/dropdown.gif" style="cursor: pointer; vertical-align: middle;" id="imgselect" onclick="showOrganizeMenu(); return false;" runat="server" /><img alt="清空" title="清空" src="~/Images/delete.gif" style="cursor: pointer; width: 17px; height: 20px; border: 0; vertical-align: middle" id="imgclear" onclick="clearOrganize()" runat="server" /><img src="~/Images/rightico.gif" style="width: 2px; height: 20px; border: 0; vertical-align: middle" id="imgright" runat="server" />
    <asp:HiddenField ID="hidOrganizeCode" runat="server" />
    <asp:HiddenField ID="hidOrganizeJb" runat="server" />
    <asp:HiddenField ID="hidOrganizepath" runat="server" Value="../" />
    <input id="hidOrganizefunction" type="hidden" runat="server" value="" />
    <input id="hidNeedJb" type="hidden" runat="server" value="" />
    <input id="hidAreaTop" type="hidden" value="0" title="固定顶部位置" />
    <input id="hidAreaLeft" type="hidden" value="0" title="固定顶部位置" />


    <%--<div class="content_wrap">--%>
    <%--<div class="zTreeDemoBackground left">--%>

    <div id="menuContent" class="menuContent" style="display: none; position: absolute; z-index: 2147483647;">
        <ul id="treeDemo" class="ztree" style="margin-top: 0; width: 208px;"></ul>
    </div>
    <div id="menuFrame" style="filter: Alpha(opacity=0); position: absolute; z-index: 2147483646; height: 372px; display: none">
        <iframe style="border: 0; width: 220px; height: 100%; position: absolute;"></iframe>
    </div>
</div>

自定义控件:后台配置

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HMFW.Web.UserControl
{
    public partial class uc_btnSelectOrganize : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender,EventArgs e)
        {
            int width = 180;
            //txtOrganize.Width = Width == 0 ? (ShowClearBtn ? (width - 36) : (width - 16)) : Width;
            //if (Width == 0)
            //    Width = 180;
            //txtOrganize.Width = ShowClearBtn ? (Width - 36) : (Width - 16);
            //width = ShowClearBtn ? (Width - 12) : (Width - 7);
            //if (width < 140)
            //    width = 140;
            imgclear.Visible = ShowClearBtn;
            imgright.Visible = !ShowClearBtn;
            hidOrganizeJb.Value = jb == -1 ? "" : Jb.ToString();
            hidNeedJb.Value = NeedJb ? "1" : "";
            imgselect.Visible = NeedSelectBut;
            imgclear.Visible = NeedClearBut;
            txtOrganize.Enabled = OrganizeEna;
        }

        #region 属性

        /// <summary>
        /// 是否显示清空按钮
        /// </summary>
        public bool ShowClearBtn { get; set; }
        /// <summary>
        /// 文本框长度
        /// </summary>
        public int Width { get; set; }

        private int jb = -1;
        /// <summary>
        /// 显示到级别   1省级 2市级 3县级 4乡镇级 5村级
        /// </summary>
        public int Jb { get { return jb; } set { jb = value; } }
        /// <summary>
        /// 地区控件Organize文件夹的相对位置  认为../
        /// </summary>
        public string BasePath
        {
            get { return hidOrganizepath.Value; }
            set { hidOrganizepath.Value = value; }
        }

        /// <summary>
        /// 给搜索按钮设置方法
        /// </summary>
        public string SetSearchFunction
        {
            get { return hidOrganizefunction.Value; }
            set { hidOrganizefunction.Value = value; }
        }
        /// <summary>
        /// 是否需要级别验证
        /// </summary>
        public bool NeedJb { get; set; }

        /// <summary>
        /// 查看按钮是否可见
        /// </summary>
        public bool NeedSelectBut { get; set; }

        /// <summary>
        /// 清空按钮是否可见
        /// </summary>
        public bool NeedClearBut { get; set; }

        /// <summary>
        /// 机构是否可编辑
        /// </summary>
        public bool OrganizeEna { get; set; }
        #endregion

        public TextBox OrganizeName
        {
            get { return txtOrganize; }
            set { txtOrganize = value; }
        }
        public HiddenField OrganizeCode
        {
            get { return hidOrganizeCode; }
            set { hidOrganizeCode = value; }
        }
    }
}

zTree参数配置

var setting = {
    view: {
        fontCss: getFontCss//,// dblClickExpand: dblClickExpand
    },isSimpleData: true,//数据是否采用简单 Array 格式,认false
    treeNodeKey: "gID",//在isSimpleData格式下,当前节点id属性
    treeNodeParentKey: "gPID",//在isSimpleData格式下,当前节点的父节点id属性
    showLine: true,//是否显示节点间的连线
    expandSpeed: "fast",//设置为快速显示动画效果
    isParent: "isParent",//查看当前被选中的节点是否是父节点
    icon: {//此属性只针对父节点有效,此属性必须与 iconClose 同时使用
        iconopen: decodeURI("iconopen"),//父节点展开时使用的图标
        iconClose: decodeURI("iconClose")//父节点折叠时使用的图标
    },check: {
        enable: true,//开启checkBox
        chkStyle: "checkBox",chkBoxType: { "Y": "","N": "" }//勾选时不关联父与子,取消勾选时不关联父与子 认值:{ "Y": "ps","N": "ps" }
    },callback: {
        beforeClick: beforeClick,//用于捕获单击节点之前的事件回调函数,并且根据返回值确定是否允许单击操作
        onCheck: onCheck,//用于捕获 checkBox / radio 被勾选 或 取消勾选的事件回调函数
        onClick: onClick,//用于捕获节点被点击的事件回调函数
        beforeExpand: beforeExpand,//用于捕获父节点展开之前的事件回调函数,并且根据返回值确定是否允许展开操作
        onExpand: onExpand//用于捕获节点被展开的事件回调函数
    }
}

function beforeClick(treeId,treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
    zTree.checkNode(treeNode,true,false);
    var nodes = zTree.getCheckednodes(true);//获取勾选当前节点集合
    if (nodes.length > 1 || nodes.length == 0) {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i] == treeNode)
                continue
            else
                zTree.checkNode(nodes[i],false,false);
        }
    }
}


function onCheck(e,treeId,treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
    var nodes = zTree.getCheckednodes(true);
    zTree.selectNode(treeId);
    if (nodes.length > 1 || nodes.length == 0) {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].gID == treeId.gID)
                continue
            else
                zTree.checkNode(nodes[i],false);
        }
    }
    nodes = zTree.getCheckednodes(true);
    if (nodes.length > 1 || nodes.length == 0) {
        return false;
    }
    hideMenu();
    CloSEOrganizeWin(treeId.gID,treeId.name);
}

function beforeExpand(treeId,treeNode) {//节点展开前
    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    var newNodes;

    var treeULDemo = $("[id='" + treeNode.tId + "_a']").next();
    var isAjaxing = treeNode.zAsync;
    if (treeULDemo != null && treeULDemo != undefined && treeULDemo.length > 0) {
        treeObj.updateNode(treeNode);
        treeObj.reAsyncChildNodes(treeNode,"refresh");
    } else {
        //startTime = new Date();
        $.ajax({
            async: false,//【重要】:设置false不然出不来数据
            type: "post",//要用post方式                 
            url: "../Organize/ZtreeForm.aspx/GetRootByChildsID",//方法所在页面方法名
            contentType: "application/json; charset=utf-8",data: '{ gid:"' + treeNode.gID + '"}',dataType: "json",success: function (data) { //请求成功后处理函数。
                //var _data = $.parseJSON(data.d);//$.parseJSON在1.2.6.min.js不兼容
                var _data = eval(data.d);//eval((+data+))
                newNodes = _data; //把后台封装好的简单Json格式赋给treeNodes
            },error: function () {//请求失败处理函数
                alert('请求失败');
            },beforeSend: function () {
                $("#" + treeNode.tId + "_a").children("#" + treeNode.tId + "_ico").css("background-image","url('" + icon + "')"); //jquery子代选择器 【暂用】
                //$("#" + treeNode.tId + "_ico").css("background-image","url('" + icon + "')");//jquery ID选择器 【暂不用】
            },complete: function () {
                treeNode.iconopen = iconopen;
            }
        });
        newNodes = treeObj.addNodes(treeNode,newNodes,true); //展开父节点
        treeObj.updateNode(treeNode);

        //endTime = new Date();
        //var usedTime = (endTime.getTime() - startTime.getTime()) / 1000;
        //showLog("加载完毕,异步加载,耗时:" + usedTime + " 秒");
    }
}

function onExpand(event,treeNode) {//节点展开
    var zTree = $.fn.zTree.getZTreeObj("treeDemo"); //加载指定节点
    zTree.selectNode(treeNode.children[0]);
}

function onClick(e,treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
    var nodes = zTree.getCheckednodes(true);//获取勾选当前节点集合
    if (nodes.length > 1 || nodes.length == 0) {
        return false;
    }
    hideMenu();
    CloSEOrganizeWin(treeId.gID,treeId.name);
}

function zTreeOnDblclick(e,treeNode) {
    alert("gID:" + treeNode.gID + " gPID:" + treeNode.gPID + " name:" + treeNode.name);
}

ajax框架调用

$.ajax({
        async: false,//【重要】:设置false不然出不来数据
        type: "post",//要用post方式                 
        url: "../Organize/ZtreeForm.aspx/GetZtreeRootList",//方法所在页面方法名
        contentType: "application/json; charset=utf-8",data: '{ gid: "' + gid + '"}',success: function (data) { //请求成功后处理函数。
            //var _data = $.parseJSON(data.d);//$.parseJSON在1.2.6.min.js不兼容
            var _data = eval(data.d);//eval((+data+))
            treeNodes = _data; //把后台封装好的简单Json格式赋给treeNodes
        },error: function () {//请求失败处理函数
            alert('请求失败');
        }
    });

webmethod读取数据

依赖注入

private static readonly OrganizeBLL iORGBLL = new OrganizeBLL();//机构信息
        private static readonly string iconopen = HttpUtility.UrlEncode(@"1_open.png");//认展开图片
        private static readonly string iconClose = HttpUtility.UrlEncode(@"1_close.png");//认收缩图片
        private static sys_Organize modelEdit = new sys_Organize();//【编辑】声明全局静态只读变量【sys_Organize】,便于获取已录入登录机构信息
        private static sys_Organize modelTownCityEdit = new sys_Organize();//镇级向上查询市级
        private static sys_Organize modelVillCityEdit = new sys_Organize();//村级向上查询市级

属性自定义

private static string gid;
        private static string gId //机构gid,便于【编辑页面】绑定数据
        {
            get
            {
                return gid;
            }
            set
            {
                gid = value;
            }
        }

节点类定义

/// <summary>
        /// 节点类
        /// </summary>
        public class Node
        {
            /// <summary>
            /// color属性
            /// </summary>
            public bool highlight;
            /// <summary>
            /// 子节点
            /// </summary>
            public List<Node> children;
            /// <summary>
            /// 展开图标
            /// </summary>
            public string iconopen;
            /// <summary>
            /// 收缩图标
            /// </summary>
            public string iconClose;
            /// <summary>
            /// 是否是父级节点
            /// </summary>
            public bool isParent;
            /// <summary>
            /// 地区gID
            /// </summary>
            public Guid? gID;
            /// <summary>
            /// 地区父gPID
            /// </summary>
            public Guid? gPID;
            /// <summary>
            /// 地区编码
            /// </summary>
            public string sAreaCode;
            /// <summary>
            /// 地区级别
            /// </summary>
            public int? iJB;
            /// <summary>
            /// 地区名称
            /// </summary>
            public string name;
            /// <summary>
            /// 删除标识
            /// </summary>
            public int? iDeleteMark;
            /// <summary>
            /// 创建日期
            /// </summary>
            public DateTime? dCreateDate;
            /// <summary>
            /// 创建人编码
            /// </summary>
            public Guid? gcreateuserId;
            /// <summary>
            /// 创建人姓名
            /// </summary>
            public string screateuserRealname;
            /// <summary>
            /// 修改日期
            /// </summary>
            public DateTime? dModifyDate;
            /// <summary>
            /// 修改人编码
            /// </summary>
            public Guid? gModifyUserId;
            /// <summary>
            /// 修改人姓名
            /// </summary>
            public string sModifyUserRealname;
        }

业务流程5,递归思想6,仿造children7,json序列化并返回

/// <summary>
        /// 读取地区列表--青海省民政厅下面一级
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string GetZtreeRootList(string gid)
        {
            gId = gid;
            List<Node> list = new List<Node>();//所有节点
            list = GetGenNode(gId);//将所有一级节点放到list中
            GetThirdChilds(ref list,gId);//递归获取节点
            return JsonHelper<Node>.ListToJsonString(list);//序列化json字符串,便于展示
        }

        /// <summary>
        /// 读取子集节点--依据参数【sAreaCode】
        /// </summary>
        /// <param name="list"></param>
        [WebMethod]
        public static void GetThirdChilds(ref List<Node> list,string gid)
        {
            BasePage bs = new BasePage();
            modelEdit = iORGBLL.GetModelById(gid);//【编辑】声明全局静态只读变量【sys_Organize】,便于获取当前登录机构信息
            /******************递归【GetThirdChilds()】是为了循环遍历节点,核心【node.children = nodeList;】追加子节点*******************/
            foreach (Node node in list)
            {
                List<Node> nodeList = GetThirdChildsID(node.gID);
                if (nodeList.Count > 0)
                {
                    if (!string.IsNullOrEmpty(gid))//【编辑】:查询到当前编辑的组织地区
                    {
                        if (modelEdit.iJB < 2)//【省】【市】级登录用户
                        {
                            if (node.iJB < modelEdit.iJB)//【编辑】组织级别依据已录入数据
                            {
                                node.children = nodeList;
                                GetThirdChilds(ref nodeList,gid);

                            }
                            else if (node.iJB == modelEdit.iJB)//【县】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.sAreaCode == modelEdit.sAreaCode)
                                    {
                                        nodes.children = GetThirdChildsID(nodes.gID);
                                        //GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                        }
                        else if (modelEdit.iJB == 2)//【县】级登录用户
                        {
                            if (node.iJB <= 0)//【省】
                            {
                                node.children = nodeList;

                                GetThirdChilds(ref nodeList,gid);
                            }
                            else if (node.iJB == 1)//【市】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 2)//【县】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gID)
                                    {
                                        nodes.children = GetThirdChildsID(nodes.gID);
                                        //GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                        }
                        else if (modelEdit.iJB == 3)//【镇】级登录用户
                        {
                            if (node.iJB <= 0)//【省】
                            {
                                node.children = nodeList;

                                GetThirdChilds(ref nodeList,gid);
                            }
                            else if (node.iJB == 1)//【市】
                            {
                                modelTownCityEdit = iORGBLL.GetModelById(modelEdit.gPID.ToString());
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelTownCityEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 2)//【县】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 3)//【乡镇】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        //GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                        }
                        else if (modelEdit.iJB == 4)//【村】级登录用户
                        {
                            if (node.iJB <= 0)//【省】
                            {
                                node.children = nodeList;

                                GetThirdChilds(ref nodeList,gid);
                            }
                            else if (node.iJB == 1)//【市】
                            {
                                modelVillCityEdit = iORGBLL.GetModelById(modelEdit.gPID.ToString());
                                modelVillCityEdit = iORGBLL.GetModelById(modelVillCityEdit.gPID.ToString());
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelVillCityEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 2)//【县】
                            {
                                modelVillCityEdit = iORGBLL.GetModelById(modelEdit.gPID.ToString());
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelVillCityEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 3)//【乡镇】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gPID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                            else if (node.iJB == 4)//【村】
                            {
                                foreach (Node nodes in list)
                                {
                                    if (nodes.gID == modelEdit.gID)
                                    {
                                        nodeList = GetThirdChildsID(nodes.gID);
                                        nodes.children = nodeList;
                                        //GetThirdChilds(ref nodeList,gid);
                                    }
                                }
                            }
                        }
                    }
                    else if (node.iJB <= bs.GetSessionCurrentUserInfo.iJB) //【新增】组织级别依据当前登录用户
                    {
                        node.children = nodeList;
                        GetThirdChilds(ref nodeList,gid);
                    }
                }
                break;
            }
        }

        /// <summary>
        /// 获所有的一级节点
        /// </summary>
        /// <param name="nodeList"></param>
        /// <returns></returns>
        [WebMethod]
        public static List<Node> GetGenNode(string gid)
        {
            List<Node> nodeList = new List<Node>();
            List<Node> childrenList = new List<Node>();
            Node node = new Node();
            Node children = new Node();
            List<sys_Organize> genList = new List<sys_Organize>();
            BasePage bs = new BasePage();//声明全局静态只读变量【BasePage】,便于获取当前登录姓名
            string name = bs.GetSessionCurrentUserInfo.sUserName;//登录用户姓名:标识【admin:加载所有组织 非admin:依据地区编码加载】【新增】

            //包含了:【新增】
            if (name.ToLower().Equals("admin"))//【admin】
            {
                genList = iORGBLL.GetList(P => P.iJB == -1 && P.iDeleteMark == 0);
            }
            else//【非admin】
            {
                genList = iORGBLL.GetList(P => P.sAreaCode == bs.GetSessionCurrentUserInfo.sAreaCode && P.iDeleteMark == 0);
            }
            if (genList != null && genList.Count > 0)
            {
                foreach (sys_Organize genItem in genList)
                {
                    //根节点 node
                    node.highlight = false;
                    node.gID = genItem.gID;
                    node.gPID = genItem.gPID;
                    node.sAreaCode = genItem.sAreaCode;
                    node.iJB = genItem.iJB;
                    node.name = genItem.sFullName;
                    node.iDeleteMark = genItem.iDeleteMark;
                    node.dCreateDate = genItem.dCreateDate;
                    node.gcreateuserId = genItem.gcreateuserId;
                    node.screateuserRealname = genItem.screateuserRealname;
                    node.dModifyDate = genItem.dModifyDate;
                    node.gModifyUserId = genItem.gModifyUserId;
                    node.sModifyUserRealname = genItem.sModifyUserRealname;
                    if (iORGBLL.GetList(P => P.gPID == genItem.gID && P.iDeleteMark == 0).Count > 0)
                    {
                        node.isParent = true;
                        node.iconopen = iconopen;
                        node.iconClose = iconClose;

                        childrenList.Add(children);
                    }

                }
                if (childrenList.Count > 0)
                    node.children = childrenList;
                nodeList.Add(node);
            }
            return nodeList;
        }

        /// <summary>
        /// 根据父节点的id获取子节点
        /// </summary>
        /// <param name="list">父节点id</param>
        /// <returns>异步调用返回List<Node></returns>
        [WebMethod]
        public static string GetRootByChildsID(string gid)
        {
            Guid id = new Guid(gid);
            //Guid.TryParse(gid,out id);

            List<Node> list = GetThirdChildsID(id);
            return JsonHelper<Node>.ListToJsonString(list);
        }

        /// <summary>
        /// 根据父节点的id获取子节点
        /// </summary>
        /// <param name="list">父节点id</param>
        /// <returns></returns>
        [WebMethod]
        public static List<Node> GetThirdChildsID(Guid? gid)
        {
            List<Node> childrenList = new List<Node>();
            foreach (sys_Organize childrenItem in iORGBLL.GetList(P => P.gPID == gid && P.iDeleteMark == 0))
            {
                Node children = new Node();
                //仿造子节点【child】属性
                //判断叶子节点是否含有子节点并设置属性
                children.highlight = false;
                if (iORGBLL.GetList(P => P.gPID == childrenItem.gID && P.iDeleteMark == 0).Count > 0)
                {
                    children.isParent = true;//认 true
                    children.iconopen = iconopen;//认 展开属性
                    children.iconClose = iconClose;//认 收缩属性
                }
                children.gID = childrenItem.gID;
                children.gPID = childrenItem.gPID;
                children.sAreaCode = childrenItem.sAreaCode;
                children.iJB = childrenItem.iJB;
                children.name = childrenItem.sFullName;
                children.iDeleteMark = childrenItem.iDeleteMark;
                children.dCreateDate = childrenItem.dCreateDate;
                children.gcreateuserId = childrenItem.gcreateuserId;
                children.screateuserRealname = childrenItem.screateuserRealname;
                children.dModifyDate = childrenItem.dModifyDate;
                children.gModifyUserId = childrenItem.gModifyUserId;
                children.sModifyUserRealname = childrenItem.sModifyUserRealname;


                childrenList.Add(children);
            }
            return childrenList;
        }

【input框既然是可编辑】
添加了:根据参数获取节点名称

【新增:依据省市县三级平台加载组织信息】

【checkBox勾选回绑

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


IE6是一个非常老旧的网页浏览器,虽然现在很少人再使用它,但是在某些特殊情况下,我们可能还需要使用IE6来访问网页。而在IE6中,我们通常会使用JavaScript来提交表单,来看一下具体操作。
PHP中的count()函数是用来计算数组或容器中元素的个数。这个函数十分方便,在编写代码时使用频率也非常高。无论你是要统计数组的长度、统计字符串中字符出现的次数还是统计对象中属性的个数,count()都可以帮助你轻松
使用 AJAX(Asynchronous JavaScript and XML)技术可以在不刷新整个页面的情况下,向服务器发送请求并接收响应。通常来说,我们使用 AJAX 请求是为了获取后台数据,并将其展示在前端页面上。然而,有时候我们只需要
Ajax(Asynchronous JavaScript and XML)是一种用于改进网页用户体验的技术,通过与服务器进行异步通信,实现在网页上局部刷新数据而不必整个页面刷新的功能。在实际开发中,我们经常需要从服务器端下载文件,而传统
本文将介绍如何通过AJAX下载Excel文件流。通过AJAX,我们可以在不刷新整个页面的情况下,向服务器发送请求并获取响应数据。在某些场景下,我们需要通过AJAX下载Excel文件流,以便于在前端使用或保存到本地。本文将详
Ajax是一种用于客户端和服务器之间的异步通信技术。通过Ajax,我们可以在不刷新整个页面的情况下向服务器发送请求并获得响应数据。而在Ajax的基础上,.get和.post是两种常用的请求方法,它们分别用于发送GET和POST请
AJAX(Asynchronous JavaScript and XML)是一种在网页上实现异步数据传输的技术。通过AJAX,网页可以在不刷新整个页面的情况下与服务器进行数据交互,提升用户体验和页面性能。在实际应用中,AJAX广泛用于表单提交、
在使用Ajax下拉加载数据的过程中,有时候会出现无法取到360度的问题。这个问题可能是由于代码逻辑的问题导致的,也有可能是网络延迟引起的。为了解决这个问题,我们需要对代码进行仔细排查,并且在合适的地方添加适当
本文将介绍Ajax和.post之间的区别。Ajax是一种用于在网页上进行异步通信的技术,能够在不刷新整个页面的情况下更新部分页面内容。.post是jQuery中的一个方法,用于向服务器发送POST请求。虽然它们都可以用于发送异步
AJAX(Asynchronous JavaScript and XML)是一种在Web页面上进行异步数据请求和交互的技术。它的出现使得页面在后台与服务器进行数据交互的同时,不需要重新加载整个页面。在网页开发中,常常需要实现文件上传功能,