2011-11-28 60 views
-4

我試圖實施美髮沙龍的yelp評論。這是我設法拼湊起來的代碼。它不工作,我實現它這種方式和外部的.js頁:Yelp評論編碼,麻煩得到它的工作

function showData(data) { 
    $.each(data.businesses, function(i,business){ 
     // extra loop 
     var bizContent = ‘<p><img src=」’ + business.rating_img_url + ‘」 img=」」/><br><a href=」’+ business.url +’」>’+ business.review_count + ‘ reviews from Yelp.com</a></p>’; 
     $(bizContent).appendTo(‘#yelpAVG’); 
     $.each(business.reviews, function(i,review){ 
      var content = ‘<div class=」comments-block」><p>Posted by <a href=」’+review.user_url+’」>’ +review.user_name + ‘ </a> on ‘ + review.date + ‘via <a href=」’+review.url+’」>Yelp.com</a>’; 
      content += ‘<p><img src=」’ + review.rating_img_url + ‘」 img=」」/><br>’; 
      content += review.text_excerpt + ‘</p>’; 
      content += ‘<p><a href=」’+review.url + ‘」>Read the full review</a><br>’; 
      content += ‘<img src=」http://media3.px.yelpcdn.com/static/200911302846157596/i/developers/yelp_logo_50x25.png」></div>’; 
      $(content).insertAfter(‘#yelpReviews’); 
     }); 
    }); 
} 

$(document).ready(function(){ 
    // note the use of the "callback" parameter 
    writeScriptTag("http://api.yelp.com/phone_search?」+ 
    「&phone=」+(408)234-0437+ 
「&ywsid=foffGrPrJNm1Vcs0Yv0rOQ」+ 
「&limit=3」+ 
「&callback=showData」); 
}); 

function writeScriptTag(path) { 
    var yelpScript=document.createElement(‘script’); 
    yelpScript.type=’text/javascript’; 
    yelpScript.src=path; 
    $(「body」).append(yelpScript); 
} 

我沒有得到任何錯誤,可能會有人幫我調試這個或者告訴我什麼我思念?

+0

你的代碼是否真的使用了那些「聰明的引號」,還是隻是剪切粘貼的結果呢? – Blazemonger

+2

幸運的評論是不是在上面的代碼 – david

+0

剪貼的結果,對不起,即時通訊非常新的JavaScript。如果我知道這些是要改變的,我不會把它們放在這裏。 –

回答

0

我測試了林特你的代碼上http://jsfiddle.net/zGkYb/和替換所有的排版後「和「用正確的一次,也正在改變這一行 ‘&手機=’+(408)234-0437 + 到 」 &手機= +(408)234-0437" +

我得到它來驗證。

我不知道這是不是所有的錯,因爲沒有HTML來測試。

檢查鏈接返工解決方案

+0

非常感謝,這是所有的印刷錯誤呢?謝謝!! –