The Google Places API is now generally available. I am trying to use the .ajax () call in jQuery to call Google Places. The error I keep returning is Unprepared SyntaxError: Unexpected token:
I am using jQuery 1.5.2. I tried 1.5.1 too, but it had the same results. I would prefer not to go to 1.6.1 if I can help him.
I made similar ajax calls similar to these other APIs, but I have problems with Google Places. Below is a very simple code example that you can play with. You will need to get your own key in the Google API console (https://code.google.com/apis/console)
jQuery.noConflict(); jQuery(document).ready(function(){ var url = 'https://maps.googleapis.com/maps/api/place/search/json'; jQuery.ajax({ url: url, dataType: 'jsonp', type: 'GET', data: { location: '33.787794,-117.853111', radius: 1000, name: 'coffee', key: 'your_key', // add your key here sensor: 'false' }, // on success success: function(data, textStatus, jqXHR){ console.log(data); }, // on failure error: function (jqXHR, textStatus, errorThrown){ console.log(jqXHR); console.log(textStatus); console.log(errorThrown); } }); });
hemmeter
source share