Problem related to wikipedia viewer, but api link is not working when i put searchTerm data that i fetch from user put inside in it

Problem related to wikipedia viewer, but api link is not working when i put searchTerm data that i fetch from user put inside in it
0.0 0

#1

$("#search").click(function(){
//gets search input
var searchTerm = $("#searchTerm").val();
//api url with searchTerm
var url = “https://en.wikipedia.org/w/api.php?action=opensearch&search=”+ searchTerm +"&format=json&callback=?";

 $.ajax({
 	type:"GET",
 	url:url,
 	async:false,
 	dataTypes:"json",
 	success:function(data){
 		console.log(data[1][0]);
 	}
 });

});
});


#2

url works fine … i pasted it into window as is and got back a object … will need to see rest of your code
would suspect your calling this outside of the call that gets your search Term and and this bit of code has already being run.


#3

could be a cross domain issue.

does it work if you use https for codepen instead of http?