Google Places API is now generally available. I am trying to use the .ajax() call in jQuery to make a call to Google Places. The error I keep getting back is Uncaught SyntaxError: Unexpected token :
I am using jQuery 1.5.2. I tried on 1.5.1 too, but that had the same results. I'd rather not move to 1.6.1 if I can help it.
I've made ajax calls like this to other APIs just since, but am having trouble with Google Places. Below is a very basic sample of code you can play with. You'll need to go get your own key at the API Console Google offers (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);
}
});
});