$(document).ready(function () {
$.getJSON({
url:"https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&origin=*&srsearch=gaby&srwhat=text&srprop=snippet&format=json",
function (result) {
$("#display").text(result.query.search[0].title);
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<p id="display"></p>
Here is the $.getJSON()
's response JSON. I use result.query.search[0].title
to get the title. Why #display
element has nothing to show?