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);
                    }
                });
            };
  • 相关阅读:
    牛顿迭代法
    C语言补遗
    Manjaro添加开机启动脚本
    tensorboard查看pytorch模型
    Kindle最佳排版记录
    01背包问题详解
    差分法介绍
    BFS详解
    UVA11732 "strcmp()" Anyone?
    LA3942 Remember the Word
  • 原文地址:https://www.cnblogs.com/Blogs-Wang/p/10833579.html
Copyright © 2011-2022 走看看