![](https://box.kancloud.cn/7640c14eaebfcfcf9a04354ddd02f3c1_737x753.jpg) # 代码示例 ~~~ <!doctype html> <html> <head> <meta charset="utf-8"> <title>沪深资讯演示!</title> <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/2.3.1/css/bootstrap.min.css"> <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> </head> <body> <script> getNews(); function getNews() { var appcode='此处填写您的APPcode'; var Authorization = 'APPCODE '+appcode; $.ajax({ type: "GET", url:"http://stock.api51.cn/news/equity_info", dataType: "json", data: {"key":"value"}, headers : {'Authorization':Authorization}, success: function(data){ console.log(data); var res =data.data[0][20104005];; console.log(res); for(var i=0;i<res.length;i++){ $('#accordion-309430').append( '<div class="accordion-group">'+ '<div class="accordion-heading">'+ '<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion-309430" href="#accordion-element-'+i+'">'+res[i].title+res[i].date+'【'+res[i].media+'】</a>'+ '</div>'+ '<div id="accordion-element-'+i+'" class="accordion-body collapse">'+ '<div class="accordion-inner">'+ res[i].content+ '</div></div></div>' ); } }, error: function(data){ console.log(data); } , }); } </script> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <h2> 沪深资讯 </h2> <p> 本页面可以在任意环境下使用,不依赖后端程序. </p> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <h4> 提示! </h4> <strong>警告!</strong> 下面若无新闻列表,请检查本页面是否填写了Appcode。请注意你的Appcode隐私安全. </div> <div class="accordion" id="accordion-309430"> </div> </div> </div> <div class="row-fluid"> <div class="span2"> </div> <div class="span6"> </div> <div class="span4"> </div> </div> <div class="row-fluid"> <div class="span6"> <div class="row-fluid"> <div class="span8"> </div> <div class="span4"> </div> </div> </div> <div class="span6"> </div> </div> </div> </body> </html> ~~~