Don't work Wikipedia Viewer

Hello,

I’m workig on my Wikipedia viewer
here is my code
Codepen

I spent a lot of time on it but can’t catch what I’m doing wrong
When I entering term in the input nothing happen and I don’t undertan what is wrong , It’s just broken my mind :face_with_symbols_over_mouth:

This is my fix,


$(function(){
    //var url = "https://en.wikipedia.org/w/api.php?action=opensearch&search=&format=json&callback=?";

  $('#search').click(function(){
    
      var searchTerm = $('#searchTerm').val();  
    
    $.ajax({
      
      type: "GET",
      url: "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchTerm + "&callback=?",
      async: false,
      dataType: 'json',
      success: function(data){
       // console.log(data[1]);
        for(var i = 0; i <=10; i++){
          $('#result').append('<a href="' + data[3][i] + '" target="blank">' + data[3][i] +'</a><br>')
        }
      },
      error: function(error){
        alert("Error")
      },
    })
    
  });
  
});
1 Like

Thank you it’s working :slight_smile: