When I type something into my search bar and hit the submit button I can briefly see that results but then they instantly disappear. Here is my JS:
$(document).ready(function(){
$("#searchBtn").on("click", function(){
var keyword = $("#search").val();
var searchURL = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&prop=extracts&exsentences=1&search="+keyword+"&callback=?";
$.ajax({
type: "GET",
url: searchURL,
dataType: "json",
success: showData,
error: function(errorMessage){
console.log("Error!");
}
});
function showData(data){
for(i=0; i < 8; i++){
var entries = '<div class=\"resultBox\"><a href='+data[3][i]+'><h4>'+data[1][i]+'</h4></a><span>'+data[2][i]+'</span></div>';
$(".searchOutput").append(entries);
}
}
});
});
Also ,here is the CodePen project: My CodePen