coderfin / byutv-jsonp

The byutv-jsonp element (<byutv-jsonp>) exposes network request functionality. It is a Polymer v1.0+ element that facilitates making JSONP requests. It uses Polymer behaviors (Byutv.behaviors.Jsonp). It is patterned after Polymer's iron-ajax element (<iron-ajax>). It has been tested using unit tests. It is part of the BYUtv Elements group of elements.

Home Page:http://coderfin.github.io/byutv-jsonp/components/byutv-jsonp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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();

imageedit_1_3713663134

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.