I am using jQuery 1.11.3 with the following code:
$.ajax({
type: "GET",
data: {
apikey: apiMusixkey,
q_track: q,
page_size: 10
},
url: "http://api.musixmatch.com/ws/1.1/track.search",
dataType: "jsonp",
contentType: 'application/json',
success: function(data) {
//console.log(json);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
I am getting the error:
parseError... [] was not called
What am I doing wrong?
Looks like you are missing a few things on your ajax. You need to specify the name of the callback function to handle the jsonp. Also, there's a format parameter you need to use with the musixmatch api. Checkout this plunker: http://plnkr.co/edit/XW6TFUJquW8o8EVpEEgU?p=preview
$(function(){
$.ajax({
type: "GET",
data: {
apikey:"309788821d050a0623303261b9ddedc4",
q_track:"back to december",
q_artist:"taylor%20swift",
f_has_lyrics: 1,
format:"jsonp",
callback:"jsonp_callback"
},
url: "http://api.musixmatch.com/ws/1.1/track.search",
dataType: "jsonp",
jsonpCallback: 'jsonp_callback',
contentType: 'application/json',
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
});