Uncaught SyntaxError: Unexpected token : (not getting response in on-response method)
gauravonly opened this issue · comments
i am getting this error even when the api call goes through successfully with status 200 but i donot get response in on-response method.
i am calling the component like this -
byutv-jsonp handle-as="json" id="getLocation" method="GET" on-
response="_handleGetLocationResponse" debounce-duration="300"
and this is how i am invoking the ajax-request -
var ajax = this.$.getLocation;
ajax.url = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
ajax.params = {
'components': 'country:IN',
'key': 'Bryurhdfh4656gnhjngfhnfghfgh',
'input': e
};
ajax.generateRequest();
How can this be solved?
It doesn't look like the googleapis support JSONP. The service has to support returning a response that is wrapped in "Padding". Take a look at the Response
tab and you will likely see that a JSON object is being returned without being wrapped. If the response is not wrapped correctly then you will get syntax errors because it is looking for something like byutv_jsonp_callback({})
not {}
.
@coderfin -- thanks a lot for your response. i got it working though via some other way.