Тема: Json request using custom search api
Hi,
I have been trying to get this code to work but nothing happens. (There is too much information in the Json result)
All i want is the titles and links to be showned when executed.
<p id="demo"></p>
<p id="demo2"></p>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
for (x in myObj.link) {
// var currentip =
document.getElementById("demo").innerHTML = myObj.items.title;
document.getElementById("demo2").innerHTML = myObj.items.link;
}
}
};
xmlhttp.open("GET", "https://www.googleapis.com/customsearch/v1?key=AIzaSyBuR2Oz3LCECz6SQy5ZOiJn7hZ2aIj_-S0&cx=007669213920302805361:-gvonkprlrq&q=bikes&alt=json", true);
xmlhttp.send();
</script>
Thanks