Google maps api error?

My code is like below

$.ajax({
            url: "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=" + type +"&keyword=cruise&key=[Myapikey]", 
            type: "GET",   
            dataType: 'json',
            cache: false,
            success: function(response){   
                debugger;
                alert(response);                   
            }           
        });

Error: “Uncaught SyntaxError: Unexpected token :”
if i use json instead of jsonp as the data type then
Error: “No ‘Access-Control-Allow-Origin’ header is present on the requested resource”

Any one have the solution for this.

you’re missing the jsonp callback in your AJAX call (if you want to use jsonp, that is). for the json case the error is self-explanatory (if not, see https://en.wikipedia.org/wiki/Same-origin_policy)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.