I am trying to get the json data from wikipedia. But, when I make my ajax call, nothing seems to be happening - no success data is logged nor is any error data logged. Here is the javascript code that I am using:
$(document).ready(function() {
$("#query").on("submit", function() {
var root = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&generator=search&redirects=1&exsentences=1&exlimit=10&exintro=1&explaintext=1&gsrnamespace=*&gsrlimit=10&gsrsearch=";
var q = encodeURI($("#q").val());
var cb = "&callback=?";
var url = root + q + cb;
$.ajax({
url: url,
type: "GET",
dataType: "json",
success: function(data) {
console.log(data);
},
error: function(error) {
console.log(error);
}
});
});
});
What should I be doing differently?