我从休息网络服务获得以下json。 -
[
{
"jobId": 1000160829,
"jobRefID": "Blue Shields key hospital contract negotiations using robust analytic tools and analyses--strategic contract roadmap, negotiation factsheets, and…",
"companyName": "Blue Shield Of California",
"jobTitle": "Senior Manger, Business Analysis",
}]
我有以下代码来使用这些数据并生成动态html内容 -
htmlAdd += '<ul class="list-unstyled">';
for (i=0; i<data.length; i++){
htmlAdd += '<li><div class="row"><div class="col-lg-2"> <img class="img-responsive" src="assets/images/companies/opentable.png" alt="" />';
htmlAdd += '</div><div class="col-lg-10"><ul align="left" class="list-unstyled">';
htmlAdd += '<li><h4><a href="#">'+data[i].jobTitle+'—</a></h4>;
htmlAdd += '</li><li>'+data[i].companyName+'—'+data[i].city+', '+data[i].state+' <a href="#"><span class="glyphicon glyphicon-map-marker"></span></a></li>';
htmlAdd += '<li class="digest">· '+data[i].jobDescription+'<a href="#">details</a></li>;
htmlAdd += '</ul></div></div></li>;
htmlAdd += '<li><hr/></li>';
}
htmlAdd += '</ul>;
document.getElementById('jobListing').innerHTML = htmlAdd;
相同的静态代码有效 -
<div class="content">
<ul class="list-unstyled">
<li>
<div class="row">
<div class="col-lg-2"> <img class="img-responsive" src="assets/images/companies/opentable.png" alt="" /> </div>
<div class="col-lg-10">
<ul align="left" class="list-unstyled">
<li>
<h4><a href="#">Senior Software Engineer — Data Science team</a></h4>
</li>
<li class="digest">· Rapidly develop proof-of-concept prototypes to prove out hypotheses
· Design, architect, implement, and debug robust, high-volume production... <a href="#">details</a></li>
<li class="digest"><a href="#">Overview</a> | <a href="#">Reviews</a> | <a href="#">Salaries</a></li>
</ul>
</div>
</div>
</li>
<li>
<hr/>
</li>
任何人都知道错误在哪里?
答案 0 :(得分:0)
以下内容应该有所帮助,因为您的原始代码缺少匹配的撇号(')
for (i=0; i<data.length; i++){
htmlAdd += '<li><div class="row"><div class="col-lg-2"> <img class="img-responsive" src="assets/images/companies/opentable.png" alt="" />';
htmlAdd += '</div><div class="col-lg-10"><ul align="left" class="list-unstyled">';
htmlAdd += '<li><h4><a href="#">'+data[i].jobTitle+'—</a></h4>';
htmlAdd += '</li><li>'+data[i].companyName+'—'+data[i].city+', '+data[i].state+' <a href="#"><span class="glyphicon glyphicon-map-marker"></span></a></li>';
htmlAdd += '<li class="digest">· '+data[i].jobDescription+'<a href="#">details</a></li>';
htmlAdd += '</ul></div></div></li>';
htmlAdd += '<li><hr/></li>';
}
htmlAdd += '</ul>';
修复你的熵宗教