Adrien Joly
Adrien Joly

Reputation: 5346

Invalid javascript/JSONP response from Soundcloud API

When I include this url as a <script> in my HTML document, Chrome does not call my callback function, whereas it works perfectly for other urls returned by soundcloud's resolve api.

After a long investigation using Chrome Dev Tools, I finally found out that the javascript returned by that call fires a SyntaxError (cf the screenshot below).

enter image description here

How can I get my callback function to be called as usual for that file?

Upvotes: 1

Views: 224

Answers (1)

Konrad Dzwinel
Konrad Dzwinel

Reputation: 37913

DevTools actually pinpoint the issue:

\u2029 character in JSON

There is an unallowed character (\u2028) in the response. SoundCloud messed up sanitizing that. This JSONP response is invalid in all browsers.

To work around it, you can simply fetch the JSON file directly. SoundCloud CORS setup seems to allow that.

Upvotes: 1

Related Questions