JSON日期未在HTML中显示

时间:2015-07-10 11:25:36

标签: javascript html json

我遇到了JSON数据的问题:我希望通过JSON URL制作新闻Feed,但不会以HTML格式显示这些信息。

$(function() {

var entries = [];
var dmJSON = "http://www.stellarbiotechnologies.com/media/press-releases/json";
$.getJSON( dmJSON, function(data) {

      var html = '<div class="panel-body"><h3 class="lead">${title}</h3>';

      html += '<time datetime="${published}">';
      html += '<span class="glyphicon glyphicon-time"></span> ';
      html += '<span class="month">${monthName}</span> ';
      html += '<span class="day">${day}</span>, ';
      html += '<span class="year">${year}</span></time></div>';
 $('#ticker').html

    },
<div id="ticker"></div>

1 个答案:

答案 0 :(得分:0)

你可以这样做:

edd@max:~$ R CMD config --cppflags
-I/usr/share/R/include
edd@max:~$ 

这将遍历<script> $(document).ready(function() { var dmJSON = "http://www.stellarbiotechnologies.com/media/press-releases/json"; $.getJSON( dmJSON, function(data) { var html = ''; // loop through all the news items, and append the // title and published date to the html variable. for(var i = 0; i < data.news.length; i++){ html += '<div>'; html += data.news[i].title html += '<br>'; html += data.news[i].published html += '</div>'; } // append all the html variable to the ticker div. $("#ticker").append(html); }); }); </script> 节点,获取newstitle日期,然后将它们附加到页面(published {id的元素{1}}。