zoukankan      html  css  js  c++  java
  • json与页面动态绑定

        function fnBindHtml(html, tempName, data) {
                $(html).find(tempName).each(function () {
                    var _this = this;
                    var thisNmae = _this.getAttribute('name') ? _this.getAttribute('name'):"err";
                    switch (_this.tagName) {
                        case "DIV": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "P": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "SPAN": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "INPUT": { _this.value = data[thisNmae]; }
                            break;
                        default: { _this.innerHTML = data[thisNmae]; };
                            break;
                    };
                });
                //return html;
            };
    
            function fnCreatHtml(rootid, tempName, data) {
                if (data == null || data.length == 0) { return false; }
    
                for (var i = 0; i < data.length; i++) {
                    var rootDivCope = $(rootid).eq(0).clone(true);
                    fnBindHtml(rootDivCope, tempName, data[i]);// rootDivCope =                
                    $(rootDivCope).show();
                    $(rootid).eq(0).after(rootDivCope);
                };
            }
    
            function fnShowNote(strCode, id) {
                $.ajax({
                    url: "/TraceApi/GetOneCameraInfo",
                    data: { code: strCode },
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,//同步异步设置,false同步,true异步
                    success: function (res) {
                        if (res.code != "1000") {
                            return;
                        };
                        var modelList = res.data;
                        if (modelList == null || modelList.length == 0) { return; }
                        fnCameraNote(modelList, id);
                    }
                });
            };
  • 相关阅读:
    REST接口设计规范总结
    Linux 下建立 Git 与 GitHub 的连接
    Linux centos修改防火墙为iptables
    一些开源软件的国内镜像源
    centOS7下安装GUI图形界面
    mysql使用锁的分析
    php后台添加默认图片
    php执行时间
    递归获取所有分类下面子分类的id
    php laravel左连接leftJoin多条where语句
  • 原文地址:https://www.cnblogs.com/Blogs-Wang/p/10833579.html
Copyright © 2011-2022 走看看