zoukankan      html  css  js  c++  java
  • JTemplates + $.Ajax

    上篇基础使用后: +AJAX

    只需要改列名即可 :<script type="text/template" id="foreach">   里的循环

    {$T.record.列名}


    <script src="~/Js/jquery-2.1.0.js"></script>
    <script src="~/Js/md5.js"></script>
    <script src="~/Js/jquery-jtemplates.js"></script>
    <script type="text/javascript">

     $(function ($) {

        
            $('#Getdatalist').on('click', function () {
                $.ajax({
                    type: "post",    //请求方式
                    async: false,
                    url: "A",
                    success: function (data) {
                        var datas = JSON.parse(data)
                        var da2 = JSON.parse(datas.ResultJson);
                        $('#foreachResult').setTemplate($('#foreach').html()).processTemplate(da2);
                    }

                });
            });

         
            
        });


     



    </script>

    <script type="text/template" id="foreach">   
            {#foreach $T.AgentList as record begin=0}  
            <tr>  
                <td>{$T.record.nAgentID}</td>  
                <td>{$T.record.sAgentCode}</td>  
                  <td>{$T.record.sCommission}</td>  
            </tr>  
            {#/for}  
         
         
        
    </script>



    <body>
          <table>  
        <thead>  
            <tr>  
                <td>Age</td>  
                <td>First?</td>  
                <td>Last?</td>  
            </tr>  
        </thead>  
        <tbody id="myistrue">  
        </tbody>  
    </table>
        <section class="featured">
        <button  id="Getdatalist">调取列表</button>
        </section>
    </body>

  • 相关阅读:
    react.js+axios跨域
    O2O项目之一 环境搭配
    跟scss相关的两个包
    [nodemon] app crashed
    解决node.js链接数据库时出现的报错 --- client does not support authentication
    在Xshell 运行angular 项目时,找不到node-sass模块,安装node-sass模块时,又出现权限问题
    ajax请求数据时,get和post的区别
    web前端如何性能优化提高加载速度
    js数组去重
    前端跨域
  • 原文地址:https://www.cnblogs.com/j2ee-web-01/p/7383792.html
Copyright © 2011-2022 走看看