hi all. I kinda need help with my Wkipedia project. The code below is meant to firstly change the position of the wrapper holding the random document button and the search bar on receiving a click response from the User and then fetch and insert the article requested for in a dynamically created div container element. When I tried to run it yesterday, it didn’t work. Please what else is missing?(some of those things I know and will correct). If I click the search icon after inserting the search value, nothing happens? Can I get some help please?
$(document).ready(function() {
let searchValue = document.getElementById("#searchString").value;
$(".sbutton").on("click", function() {
// code to push the wrap div element and icon up the container
$(".wrap").animate({
marginTop: "5px"
});
let baseUrl = " https://en.wikipedia.org/w/api.php? ";
let tailUrl =
"action=opensearch&format=jsonfm&search=" + searchValue + "&limit=10";
let wikiLink = baseUrl + tailUrl;
$.ajax({
url: wikiLink,
type: "GET",
dataType: "json",
success: function getWikiData(data) {
let dDiv = document.createElement("div");
dDiv = "content";
dDiv.className = "secondDiv";
document.getElementByClassName("container").append(dDiv);
for (var i = 0; i < data.opensearch.search.length; i++) {
$("#content").appendChild(
"<p>" + data.opensearch.search[2].title + "</p>"
);
}
},
error: function(error) {
console.log(error);
}
});
});
});