来自 Soundcloud API 的 javascript/JSONP 响应无效 [英] Invalid javascript/JSONP response from Soundcloud API

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

问题描述

当我包含 )在回应中.SoundCloud 搞砸了消毒.此 JSONP 响应在所有浏览器中均无效.

要解决此问题,您只需直接获取 JSON 文件即可.SoundCloud CORS 设置似乎允许.

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

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

解决方案

DevTools actually pinpoint the issue:

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.

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

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