Im trying to call an API using ajax. The api is https://rapidapi.com/brianiswu/api/genius?endpoint=apiendpoint_d2f41ea4-7d5c-4b2d-826a-807bffa7e78f
I cant make it work.I searched in internet but i cant find or understand a solution for my problem. Its easy probably, but please help me This is my code:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>MusicApp</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"><script src="https://code.jquery.com/jquery-3.4.1.js"></script></head><body><form><input type="text" id="inputText"><input type="submit" name="submit" id="submitBtn"></form><div id="text"></div></body><script>
$(document).ready(function(){
var api="1f57380a81msh394cf453f4d1e73p1a0276jsnab0cd43f0df7";
$('#submit').click(function(){
artist=$('#inputText').val();
$.ajax({
method:"GET",
url: "https://genius.p.rapidapi.com/search?q=" + artist + "&appid=" + api,
success:function(resp){
alert("successfully");
},
error:function(){
alert("Something went TEREBLY WRONG!!!! \nYOU BROKE IT!");
}
})
})
})</script></html>