Can't seem to get search working on Wikipedia Viewer

Can't seem to get search working on Wikipedia Viewer
0.0 0

#1

I can’t seem to get the search button working on my Wikipedia viewer. I’ve read and reread my code.

Here is the link to my pen: https://codepen.io/sanskrtapanditah/pen/VxLvXZ?editors=1010
And here is my javascript code:

const uri = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch="+ $('#search_box').val() + "&prop=extracts&exintro&explaintext&exsentences=1&exlimit=max&callback=?";

$(document).ready(function() {
  $('#search_box').on('input', function() {  
    $.getJSON(uri, function(json) {
      pages = json.query.pages;
      var titles = [];
      var extracts = [];
      for (var page in pages) {
        titles.push(pages[page].title);
        extracts.push(pages[page].extract);
      }
      var listing = "";
      for (i = 0; i < titles.length; i++) {
        listing += '<div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><a href="https://en.wikipedia.org/?curid=';
        listing += '">'
        listing += titles[i];
        listing += '</a></h3> </div> <div class="panel-body">';
        listing += extracts[i]
        listing += '</div></div>'
      }
      $("#search_results").html(listing);

      });
    event.preventDefault();
  });
});

Thanks in advance for any insight.