当我使用 jquery 的 $.getJSON 方法加载以下 JSON 时,我收到以下错误 Uncaught SyntaxError: Unexpected token : JSON 是使用 Java 的 Simple JSON 库在 servlet 中以编程方式创建的,所以我认为 json 中存在结构错误的可能性很小是加载的 JSON
{"links":[{"link":"http:\/\/projects-sushilkumar.rhcloud.com\/YTDownload?url=http:\/\/o-o---preferred---iad09s20---v17---lscache7.c.youtube.com\/videoplayback?upn=OE7v3mttmjE!sparams=cp%2Cgcr%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire!fexp=922401%2C920704%2C912806%2C911406%2C912706!key=yt1!itag=37!ipbits=8!signature=3E14ACACF3CD2F3DB18C6D0D54C00A49E6CAA2BE.B6CD8982AAD85086CC1CCA42F9207FF9AF6DBC84!mv=m!sver=3!mt=1345701731!ratebypass=yes!source=youtube!ms=au!gcr=us!expire=1345726167!ip=50.19.68.176!cp=U0hTSldNVF9LUUNOM19PR1hCOjAzTWtjV2V2eTRu!id=9d8c9310d90eae67!quality=hd1080!fallback_host=tc.v17.cache7.c.youtube.com!type=video\/mp4&title=Tujhe Bhula Diya \/ Hello - Gaurav (Synchronicity)\n - YouTube.mp4","type":"mp4"},{"link":"http:\/\/projects-sushilkumar.rhcloud.com\/YTDownload?url=http:\/\/o-o---preferred---iad09s20---v16---lscache6.c.youtube.com\/videoplayback?ip=50.19.68.176!upn=OE7v3mttmjE!sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cgcr%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire!fexp=922401%2C920704%2C912806%2C911406%2C912706!mt=1345701731!key=yt1!algorithm=throttle-factor!burst=40!ipbits=8!itag=17!sver=3!signature=1C4B63A105890A1B7C63563C1CCDB2187F7FCF74.64100D94E68D0327F78C1BCD89ECB77E1D2D83A3!mv=m!source=youtube!ms=au!gcr=us!expire=1345726167!factor=1.25!cp=U0hTSldNVF9LUUNOM19PR1hCOjAzTWtjV2V2eTRu!id=9d8c9310d90eae67!quality=small!fallback_host=tc.v16.cache6.c.youtube.com!type=video\/3gpp&title=Tujhe Bhula Diya \/ Hello - Gaurav (Synchronicity)\n - YouTube.3gpp","type":"3gpp"}]}
这是执行以下操作的代码$.getJSON()
:
$('button').click(function() {
$.getJSON('http://projects-sushilkumar.rhcloud.com/YTGrabber?url=http://youtube.com/watch?v=nYyTENkOrmc&feature=g-all-lik&callback=?',
function(data) { alert('loaded'); });
});