Why do I get Uncaught SyntaxError: Unexpected token ILLEGAL Why do I get Uncaught SyntaxError: Unexpected token ILLEGAL json json

Why do I get Uncaught SyntaxError: Unexpected token ILLEGAL


The problem is that the description field in track id #159500192 ('Summer Chords Pt. 2' (Electro House Mix)) has invisible characters that are not legal inside of JavaScript strings, so the JavaScript parser chokes when trying to the run the JSONP response as a script. SoundCloud should encode these values when serving content via JSONP.

Because SoundCloud supports CORS, you don't need to use JSONP at all. You can simply request the file directly, by removing the callback=? parameter and using dataType: json (not jsonp):

jQuery.ajax({ url: "https://api.soundcloud.com/resolve?url=http://soundcloud.com/[USER]/tracks/&format=json&consumer_key=[KEY]",              dataType: 'json',              success: function(d) { console.log(d); }});