Hello I am having some problems with using ajax to get the json data.
I am using the https://market.mashape.com/andruxnet/random-famous-quotes api to get the random quotes but my code does not seem to be working. When I press the button there is no response. I do not get an error message, nothing is written to the console, and there is no error alert. I’m not sure what I have done wrong at this point
here is my JS
$(document).ready(function() {
$.ajax({
url: "https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous",
beforeSend: function(xhr) {
xhr.sendRequestHeader("X-Mashape-Key", "jW0FyGBFqymshTXPHcdNJY0Jqczpp1NinCyjsnaRYZwqITNUwO");
xhr.sendRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.sendRequestHeader("Accept", "application/json");
},
dataType: "json",
type: "POST",
success: function(data) {
var quoteData = data;
var quoteText = quoteData["quote"];
var quoteAuthor = quoteData["author"];
$("#quote").html(quoteText);
$("#author").html(quoteAuthor);
console.log(data);
},
error: function(err) { alert(err); }
});
});