Das OnClick() Ereignis der Schaltfläche nicht leitet anywhere.There könnte ein Problem mit dem Erfolg sein() von ajax.I kann nicht herausfinden, was, wie ich bin neu dazu.Ajax Erfolg() funktioniert nicht, wenn API Aufruf
var currentAuthor="";
var currentQuote="";
$(document).ready(function(){
$("#getMessage").on("click",function(){
$.ajax({
header:{
"X-Mashape-Key":"xE5Raw3acMmsh4dpp6HEk5WSbJtTp1X9TL3jsnue3VRzr5vNNa",
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded"
},
url:"https://andruxnet-random-famous-quotes.p.mashape.com/?cat=",
success: function(response){
var r=json.parse(response);
currentQuote=r.quote;
currentAuthor=r.author;
$("#author").html(r.author);
}
});
});
});
Erhalten Sie irgendwelche Fehler in der Konsole? – Hodrobond
Ich habe versucht, Ihren Code in eine Geige zu kopieren und ich habe eine 401, die Kopfzeile "X-Mashape-Key" wird nie hinzugefügt – Nicolas
Also, was soll ich tun? @Hodrobond – aayushi