view raw
Drum Drum - 9 months ago 39
Javascript Question

How To Use JSON Returned From a URL in Javascript?

I have a URL which returns JSON data. I would then like to use some parts of this data in Javascript. At the moment I'm getting an 'Uncaught Syntax Error' in the console when I run it.

My code looks like this:

var myAPIcall = "";

$.get(myAPIcall, function( data ) {
console.log("Place ID = " + data.results.place_id);
}, "json" );

It's the JSON itself which is causing the error.

How can I get the JSON (specifically the place_id, but I'd be happy with any of it) to display with the
? If I understand that much I should then be able to move on and use the place_id in my code.



Check our query. Removing callback=? will result in a valid JSON :-)

var myAPIcall = "";

    $.getJSON(myAPIcall, function( data ) {
<script src=""></script>