I am stuck at wikipedia viewer ? Need help


All is fine according to me but output shows and disappears in less than second.Here is my link: https://codepen.io/alihashir4799/pen/GvEXWK?editors=1011


A basic debugging step would be to output the AJAX data to the console. When I did that there was no data getting back from the AJAX call, nothing.

When I get rid of the line async:false, it works fine:

      url:"https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchItem + "&format=json&callback=?",
      success: function(data){
        // etc ...


Forms refresh the page by default when you submit. You need to add a parameter in the click handler (usually named e or event), then add e.preventDefault() in the function body.

$('#search').click(function(e) {
  // rest of the code...


In addition to the suggestion from @kevcomedia about e.preventDefault(), consider attaching a submit event handler to your form instead of a click handler to your button. This way, the button will still work and your input field will also search when you press Enter.

$("form").submit(function(e) {
  var searchItem = $("#input").val();


Thank you for great information about forms.Program works now!.