3

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?

vladimir
  • 13,428
  • 2
  • 44
  • 70
Francesco
  • 24,839
  • 29
  • 105
  • 152
  • Why is your dataType set to jsonp? – jarz Aug 25 '15 at 00:41
  • jsonp because it's an external call and i get No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. if i dont use jsonp – Francesco Aug 25 '15 at 00:44
  • Are you sending the jsonp callback somewhere? – jarz Aug 25 '15 at 01:01

1 Answers1

3

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);
    }    
  });
 });
jarz
  • 732
  • 7
  • 20
  • unbelievable... how idi you do it?? it works! it works! it works!t works! it works! it works!t works! it works! it works!t works! it works! it works!t works! it works! it works!t works! it works! it works! – Francesco Aug 25 '15 at 01:52