zoukankan      html  css  js  c++  java
  • ajax. 通过后台接口 渲染数据

    <!--热门文章-->
    <div class="remenwenzhang">
    <div class="news-recommend">
    <div class="news-recommend-title">推荐</div>
    <ul class="news-recommend-list">
     
    </ul>
    </div>
    </div>
     
    <script type="text/javascript">
    $.ajax({
    url: "https://gateway.caixin.com/api/data/cms-data/getPvRank",
    type: "get",
    dataType: "jsonp",
    success: function(res) {
                    console.log(res);
                    console.log(typeof(res));
                    var _data = res.data;
                    console.log(_data);
                    var str = '';
                    // 注意:输出的i与obj分别为下标与单个的对象
                    $.each(_data, function(i, obj) {
                        console.log(i);
                        console.log(obj);
                        str += '<li>';
                        str += '<a url="' + obj.link + '"/>';
                        str += '<span>'+ obj.title + '</span>';
                        str += '</li>';
                    });
                    $(".news-recommend-list").append(str);
                }
    })
    </script>
  • 相关阅读:
    linux tmux基本操作
    AJAX json集合传入Controller后台
    python 数据读取
    appium
    接口测试设计思路
    python 常用模块
    接口测试程序部分
    测试用例设计思路
    mock_待续
    网站收藏
  • 原文地址:https://www.cnblogs.com/ylblogs/p/10769624.html
Copyright © 2011-2022 走看看