美文网首页
ajax获取bitkk行情-html

ajax获取bitkk行情-html

作者: Symbian米汤 | 来源:发表于2018-07-02 16:58 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/bootstrap.css">
        <script src="js/jquery-3.3.1.min.js"></script>
        <script src="js/bootstrap.js"></script>
        <script src="js/knockout-3.4.2.js"></script>
        <title>bitkkData</title>
    </head>
    
    <script type="text/javascript">
        //动态刷新
        setInterval("myInterval()", 1000);//1000为1秒钟
        function myInterval() {
            myfunction();
        }
        window.onload = myfunction;
        function myfunction() {
            //清空所有的子节点
            $("#J_TbData").empty();
    
            $.ajax({
                type: "GET",
                url: "http://api.bitkk.com/data/v1/allTicker",
                cache: false,
                async: false,
                dataType: "json",
                success: function (data, textStatus, jqXHR) {
                    var jsondata = JSON.stringify(data);
    
                    console.log(typeof (jsondata));
                    console.log(typeof (data));
                    for (var p in data) {
                        var $trTemp = $("<tr></tr>");
                        //往行里面追加 td单元格
                        $trTemp.append('<td><span class="label label-success">'+p+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].high+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].low+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].buy+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].sell+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].last+'</span></td>'+
                            '<td><span class="label label-danger">'+data[p].vol+'</span></td>');
    
                        $trTemp.appendTo("#J_TbData");
                    }
                }
    
            })
        };
    
    </script>
    
    
    <body class="table-responsive">
      <div class="container">
          <div class="row col-xs-6 col-md-9 col-lg-12 ">
              <table  class="table table-striped table-hover table-condensed ">
                  <thead>
                  <tr >
                      <th>币种</th>
                      <th>最高价</th>
                      <th>最低价</th>
                      <th>买一价</th>
                      <th>卖一价</th>
                      <th>成交价</th>
                      <th>成交量</th>
                  </tr>
                  </thead>
                  <tbody  id="J_TbData">
                  <tr >
                  </tr>
                  </tbody>
              </table>
          </div>
      </div>
    </body>
    </html>
    
    
    
    

    相关文章

      网友评论

          本文标题:ajax获取bitkk行情-html

          本文链接:https://www.haomeiwen.com/subject/iqmluftx.html