从SoundCloud API无效的JavaScript / JSONP响应 [英] Invalid javascript/JSONP response from Soundcloud API

查看:192
本文介绍了从SoundCloud API无效的JavaScript / JSONP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我包括<一个href=\"https://api.soundcloud.com/tracks/128149524.json?callback=__loadjsonp__3&client_id=9d5bbaf9df494a4c23475d9fde1f69b4\"相对=nofollow>此网址为&LT;脚本&gt;我的HTML文档中,Chrome不叫我的回调函数,而它完全适用于其他通过网址的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.

使用Chrome开发工具长时间的调查后,我终于发现,通过调用返回的JavaScript触发一个SyntaxError(CF下面的截图)。

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).

如何得到我的回调函数被调用照常该文件?

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

推荐答案

DevTools实际确定问题:

DevTools actually pinpoint the issue:

有一个不允许的字符( \\ u2028 )中的反应。的SoundCloud搞砸了消毒的。这JSONP响应是在所有浏览器无效的。

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

要解决它,你可以简单地直接获取JSON文件。的SoundCloud CORS设置似乎以允许

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

这篇关于从SoundCloud API无效的JavaScript / JSONP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆