我正在尝试将数据添加到空var中,但数据未被存储。
致电web.xml
时,它显示为空。我错过了什么?谢谢!
...
<context-param>
<param-name>resteasy.role.based.security</param-name>
<param-value>true</param-value>
</context-param>
...
答案 0 :(得分:1)
var data = '[{"name": "h1"}, {"name": "h2"}]';
var hotelData = JSON.parse(data);
function hotelList(){
var hotel_list = '';
(hotelData || []).forEach(function (hotel, index) {
hotel_list += '<li class="hotel" data-index="'+ index +'">'+ hotel.name +'</li>';
});
document.getElementById("hotel-listing").innerHTML = hotel_list;
};
document.addEventListener('DOMContentLoaded', function() {
hotelList();
});
&#13;
<div id="hotel-listing"></div>
&#13;