Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I display multiple (but seperate) JSON requests on the same page
    primarykey
    data
    text
    <p>I have a web page where I want to display hotel reviews from the yelp.com API for a number of hotels.</p> <p>I have managed to do this for one hotel, and it works perfectly displaying the data under that specific hotel's details on the page. However, how can I now multiply this process so that I have separate reviews for each hotel?</p> <p>My web page can be seen at <a href="http://dev.bhx-birmingham-airport.co.uk/pages/hotels.php" rel="nofollow noreferrer">http://dev.bhx-birmingham-airport.co.uk/pages/hotels.php</a> to get an idea of what I'm trying to do.</p> <p>The source code I am using so far looks like:</p> <pre><code>&lt;script&gt; function showData(data) { $.each(data.businesses, function(i,business){ // extra loop $.each(business.reviews, function(i,review){ var content = '&lt;p&gt;Review - ' + review.text_excerpt + ' &lt;a href="http://www.yelp.co.uk/biz/hilton-birmingham-metropole-hotel-solihull"&gt;Read more...&lt;/a&gt;&lt;/p&gt;'; content += 'Rating - &lt;img src="' + business.rating_img_url + '" /&gt;'; content += '&lt;p&gt;Date Added - ' + review.date + '&lt;/p&gt;'; $(content).appendTo('#hilton'); }); }); } $(document).ready(function(){ // note the use of the "callback" parameter writeScriptTag( "http://api.yelp.com/business_review_search?"+ "term=hilton%20metropole"+ "&amp;location=B26%203QJ"+ "&amp;ywsid=[...]"+ "&amp;callback=showData"); // &lt;- callback }); function writeScriptTag(path) { var fileref = document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", path); document.body.appendChild(fileref); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload