更新:
啊,我现在看到您的错误。
businesses.reviews是一个数组(每个企业可以有多个评论),因此您必须遍历每个企业和每个企业的评论。
我必须更改一些内容才能使其在我的测试床上运行,但是您可以在此处看到运行此代码的示例: http :
//bit.ly/4mTxPp
yelp当前支持JSONP调用,因此您可以将代码更改为:
<script src="http://pre.jquery.com/jquery-latest.js"></script><script>function showData(data) { $.each(data.businesses, function(i,business){ // extra loop $.each(business.reviews, function(i,review){ var content = '<p>' + review.text_excerpt + '</p>'; content += '<p>' +review.date + '</p>'; $(content).appendTo('#review'); }); }); }$(document).ready(function(){ // note the use of the "callback" parameter writescriptTag( "http://api.yelp.com/business_review_search?"+ "term=hilton%20metropole"+ "&location=B26%203QJ"+ "&ywsid=lOoGGbkYpVmTvxHlWGT2Lw"+ "&callback=showData"); // <- callback});function writescriptTag(path) { var fileref = document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", path); document.body.appendChild(fileref);}</script>


