解析json数据时抛出错误

时间:2016-04-15 13:07:35

标签: javascript json

我将json数据添加到html div并解析。在本地工作正常。但是当我们从服务器运行文件时它会抛出错误。错误是"意外的令牌o"。

var data = $.parseJSON($("#json-data").html());
//console.log(data);
var now = new Date();


var events = [];
if (data != undefined && data.results.assets.length > 0) {

    var dayevents = [];

    $.each(data.results.assets, function(i, entry) {
        var d = entry.metadata.EventDate;

        $('#calender-list').append('<div class="events-list-main"><div class="events-list"><div class="event-title">' + entry.metadata.EventName + '</div><div class="event-addr">' + (entry.metadata.EventDate) + '-' + (entry.metadata.EventEndDate). + ' ' + (entry.metadata.EventEndDate). + '<br/>' + entry.metadata.EventAddress + '</div><div class="event-desc">' + entry.metadata.EventDesc + '</div><a href="' + entry.metadata.EventURL + '" target="_blank" class="event-website">SEE EVENT WEBSITE<em class="icon-go"></em></a></div></div>');

    });
}

fiddle

1 个答案:

答案 0 :(得分:1)

.+(entry.metadata.EventEndDate). +

它们应该类似于(entry.metadata.EventEndDate) + '<br/>'

fiddle