So this is what it does lets say i search apples.The first search i may get a blink of the data being pulled. Then the second search of apple i get the information required fully.
This is the codepen if you want to see the bug: https://codepen.io/chrism3ca/full/ryPJzW/
$( document ).ready(function() {
//Getting the input value when keydown is enter
$("#searchBar").on("keydown",function search(e) {
var newSearch;
if(e.keyCode == 13) {
newSearch = $('#searchBar').val();
//Requesting data from api
$.ajax({
type: 'GET',
url:"https://en.wikipedia.org/w/api.php?action=opensearch&search="+newSearch+"&limit=10&namespace=0&format=json",
data: {
format: 'json'
},
dataType: 'jsonp',
success: function(data){
//printing similar titles
for (i=0; i < data[1].length; i++){
$('#searchTitle').append(data[1][i] + "</br>");
}
//printing summary
for (k=0; k < data[2].length; k++){
$('#Summary').append(data[2][k] + "</br>");
}
}
});
}
});
});