WikiPedia Viewer-Content Not updating


#1

This is my js file. I have a bit of problem which while entering search for next time content is not updating even though request is successful. What should I do to update my content?

$(document).ready(function () {
	$("#finding").unbind().click(function (e) {
		e.preventDefault();
		var searchQuery;
		searchQuery="Vikram"
		searchQuery = $("#searchQuery").val();
		console.log(searchQuery);

	
	
	var playListURL = "https://cors-anywhere.herokuapp.com/https://en.wikipedia.org/w/api.php?action=opensearch&search="+searchQuery+"&limit=10&namespace=0&format=json";
	$.getJSON(playListURL, function (data) {
		myData=data;
		console.log(myData);
		displayData(data);
	});
});
});
console.log(myData);
function displayData(data) {
if(myData!==null){
for (var i = 1; i < 10; i++) {
			console.log(myData);
			$("#first").append("<p>" + myData[1][i] + "</p>"+"<p>" +myData[2][i]+"</p>"+myData[3][i]+"<hr>" )
	}
}	
}

If this is being asked already please provide the links for the same.


#2

When you scroll down the page, do you see your new results? I’m guessing, but it looks like you only ever append to #first… like this: $("#first").append(...). You don’t clear the old data.

If it isn’t that, can you post a link to your project so we can see it in action?


#3

Yes that exactly happening… first time its all perfect but when pressing the button for second time it just well appending. so both results i.e first one and recent one is there…