I want to display results pulled using Google Knowledge Graph API by using the javascript code provided by the official documentation on my HTML file. Refer here:
var service_url = 'https://kgsearch.googleapis.com/v1/entities:search';
var params = {
'query': 'united_kingdom',
'limit': 10,
'indent': true,
'key': '(myapikey)',
};
$.getJSON(service_url + '?callback=?', params, function(response) {
$.each(response.itemListElement, function(i, element) {
$('<div>', {text:element['result']['name']}).appendTo(document.body);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Why isn't it returning any result? I inspected it and saw that there is a javascript error (undefined).
I think that your script is correct. In my environment, your script worked. So can you confirm the following points?
If this was not useful for you, I'm sorry.