0

I'm trying to call Google Places API1 using jQuery but it seems to be failing because of a cross-domain security issue. I've tried to make this request a JSONP request and it runs but the server returns straight up JSON so the parsing fails within jQuery. Has anyone found a solution for this?

var requestUrl = "https://maps.googleapis.com/maps/api/place/search/json?location=" +
                   location.coords.latitude + "," + location.coords.longitude + "&radius=100&types=restaurant&sensor=false&key=<<api key here>>";

// Called with
$.getJSON(requestUrl + "&callback=?", onLocateRestaurants);
// or
$.ajax({
    url: requestUrl,
    type: 'GET',
    dataType: 'jsonp',
    crossDomain: true,
    callback: 'test',
    contentType: 'application/json',
    success: onLocateRestaurants2,
    error: defaultErrorHandler
});
Jeremy Edwards
  • 14,620
  • 17
  • 74
  • 99

1 Answers1

2

@Jeremy: I can post the closing answer for you.

The Places API does not support JSON-P. See the following question (as linked to by Ken Browning) for more details:

Querying Google Places API using jQuery

Community
  • 1
  • 1
Victor Zamanian
  • 3,100
  • 24
  • 31