hii!, Can anyone help me with wikipedia page viewer app. I’m not getting back my ajax call request in codepen.io.
My project works completely fine on my local browser but it’s not giving results on codepen.
here is my jquery code >
$(function () {
$(".search-button").click(function () {
var input = $("#search").val();
var searchApi = "http://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + input + "&format=json&callback=?";
var searchResult = searchApi + input;
$.ajax({
type: 'GET',
url: searchResult,
dataType: 'jsonp',
success: function (data) {
$(".output").html(" ");
for (var i = 0; i <= data[1].length; i++) {
$('.output').prepend("<li><a href = " + data[3][i] + ">" + data[1][i] + "</a><p>" + data[2][i] + "</p></li>");
}
}
});
});
});
@sahil_malik,
when making AJAX calls through CodePen you are dealing with what is known as a CORS request I would recommend you read the following sources (they will help you overcome your issue):