I am doing a small school project that is basically a web app that searches nearby restaurants by keywords = restaurant and the specific cuisine that the user chooses. However, I have a problem when getting the website of the place and putting it in "a" tag and when I press the link to test it, it says that the page cannot be found. But the link works perfectly when I copy and paste the link in a new tab in the browser.
This is the jquery that deals with the json output of my request:
var restaurantContactDetails = "https://maps.googleapis.com/maps/api/place/details/json?reference="+restaurant_reference+"&key=API_KEY";
$.getJSON(restaurantContactDetails,function(jsondata){
$("#restaurant_contact").html("Contacts: " + "<p> UK: " + jsondata.result.formatted_phone_number+ ","+ " International: " + jsondata.result.international_phone_number+"</p>");
//$("#restaurant_contact").append("<p> International: " + jsondata.result.international_phone_number+"</p>");
var website = jsondata.result.website;
//alert(website);
console.log(website);
$("#restaurant_website").append("<a href=website >" + website+"</a>");
for(var i = 0; i < Object.keys(jsondata.result.reviews).length;i++){
$("#Client_reviews").append("<p class=rust_reviews>"+"<h4 class=text-success>"+jsondata.result.reviews[i].author_name+"</h4>"+"<pre>"+jsondata.result.reviews[i].text+"</pre>");
}
});
I should mention that the place website sometimes is a specific link like this: http://www.premierinn.com/en/hotel/ABEPTI/aberdeen-city-centre?cmp=GLBC Any suggestions?
Try this:
$("#restaurant_website").append("<a href=" + website + ">" + website+"</a>");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments