Help with Wikipedia Viewer- Search results are not displaying

Help with Wikipedia Viewer- Search results are not displaying
0

#1

Hello I am currently on the wikipedia viewer project. I am having problems trying to display my search results. I got the wikipedia api working and when i placed in a browser it showed the JSON object that i needed. I used the For loop to iterate through the object and display the title and content of each page but it is not displaying it. This is my javascript code:

function processArticlePages(item) {

   for (i = 0; i < item.query.length; i++) {

 $("#results").html("<p>" + item.query.title[i] + "</p>");

 }

}


$(".search_button").on("click", function() {
   var searchString = $("#searchBox").val();

  if (searchString) {

  $.ajax({
   type: "GET",
   data: {    
     action: 'query',
     generator: 'search',
     gsrlimit: 5,
     origin: '*',
     gsrsearch:searchString,
     format: 'json',
   },
   datatype: "json",
   url: "https://en.wikipedia.org/w/api.php",

   success: processArticlePages

 });
 return false;
   }
 });

Thanks


#2

Well I’m not kinda professional but you might wanna try success:processArticlePages(response) option ? You need to assign processArticlePages(item) items in success line.


#3

OK let me try that. Cheers bruv