132
rated 0 times
[
134]
[
2]
/ answers: 1 / hits: 15806
/ 8 Years ago, mon, may 2, 2016, 12:00:00
I am trying to use Wikipedia's API to make a search query, then append those results to my page. This is what I have so far :
use strict;
$(document).ready(function(){
function searchWikipedia(searchCriteria){
$.getJSON('https://en.wikipedia.org/w/api.php?action=query&format=json&limit=15&callback=?&titles=' + searchCriteria, processResult);
}
$('#btn').click(function searchCriteria() {
var searchCriteria = $(input[name=Wikipedia]).val();
searchWikipedia(searchCriteria);
})
function processResult(apiResult){
if (apiResult.query.pages[-1]){
console.log(No results);
} else {
for (var i = 0; i < apiResult.length; i++){
$('#display-result').append('<p>'+apiResult+'</p>');
}
}
}
});
So far nothing appends to my html and there's no errors in my console.
More From » jquery