0

I have a problem with display json url from google. When i load my webpage i have a empty screen... no errors, no response

 $(document).ready(function() {

   $.getJSON('https://maps.googleapis.com/maps/api/place/details/json?reference=CpQBhQAAAO74ZZ0bYHAkFKV3rXb-sMyPIvTUaP8olqsu61cyWIR-f3bTpcN0PU_VA3RWTLyH3NeJLWxOpXBqmczZDfYE6EnYbayYl6HWn4xNZA8fJURcNiY4dbzWaTfjxx9HDe3C1JCLZUDRqHwlVudODDRmUsiiJMVSMJniKyimt9-qGgn1paABdlGXU7uduPHUjy9hoxIQr4QJPQjk5yt9FXzzFJnhQxoU3NRNlO-q1Q8y36urd8F_lsvgWHY&sensor=true&key=AIzaSyDSKYz8pCRLHglMPGo1ca6E-geDUQw', function(data) {
    $('#dictionary').empty();

 var html = '<div class="entry">';
 html += '<h3 class="term">' + data.result.name + '</h3>';
 html += '<div class="part">' + data.result.website + '</div>';
 html += '<div class="definition">';
 html +=  data.result.rating;
 html += '</div>';
 html += '</div>';
 $('#dictionary').append(html);


   });
 });

Url is correct, structure of json is also correct. Function works good only when i want read json from file for example (not from url):

$.getJSON('fileofjson.json'......

Thanks for help. Michal.

PS. Parsing JSON from Google Map This is my first topic of this problem... here is a structure of json file.

I try to read json from google by:

 $('#container').load('http://google.com'); 
  $.ajax({
url: 'https://maps.googleapis.com/maps/api/place/details/json?reference=CpQBhQAAAO74ZZ0bYHAkFKV3rXb-sMyPIvTUaP8olqsu61cyWIR-f3bTpcN0PU_VA3RWTLyH3NeJLWxOpXBqmczZDfYE6EnYbayYl6HWn4xNZA8fJURcNiY4dbzWaTfjxx9HDe3C1JCLZUDRqHwlVudODDRmUsiiJMVSMJniKyimt9-qGgn1paABdlGXU7uduPHUjy9hoxIQr4QJPQjk5yt9FXzzFJnhQxoU3NRNlO-q1Q8y36urd8F_lsvgWHY&sensor=true&key=AIzaSyDSKYz8pCRLHglMPGo1ca6E-geDUQw',
type: 'GET',
success: function(res) {
    var headline = $(res.status).find('a.tsh').text();
    alert(headline);
}
});

but alert doesn't work, empty screen. Can somebody help me to parse this url to html? Thanks a lot.

Community
  • 1
  • 1
Michal
  • 113
  • 1
  • 4
  • 13

1 Answers1

0

See this related question and my answer. You can't, in general, load JSON from a remote source using Javascript, because of the Same Origin Policy. You'll need to use JSONP instead, if the Google API offers this.

Community
  • 1
  • 1
nrabinowitz
  • 55,314
  • 10
  • 149
  • 165