为什么此JSONP供稿会抛出“意外令牌"?错误? [英] Why is this JSONP feed throwing "Unexpected Token" error?

查看:106
本文介绍了为什么此JSONP供稿会抛出“意外令牌"?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过此远程JSONP feed jQuery的.

I'm trying to grap this remote JSONP feed via jQuery.

每次尝试时,都会出现错误未捕获的SyntaxError:意外的令牌("或类似的错误.

Every time I try, I get an error of "Uncaught SyntaxError: Unexpected token (" or similar.

我是在做错什么还是在JSONP数据中格式化或转义错误?

Am I doing something wrong or is something in the JSONP data formatted/escaped incorrectly?

提琴: http://jsfiddle.net/callmeed/d3tSX/2/

var _event_url = "http://calvaryslo.onthecity.org/plaza/*events*?format=json";
$.ajax({
    type: 'GET',
    url: _event_url,
    dataType: 'jsonp',
    success: function(msg) {
        alert(msg.length);
    }
});​

推荐答案

因为此供稿返回JSON,而不是javascript函数调用:

Because this feed returns JSON, not a javascript function call:

[{Query172031345640518702567_1334079878875({...

但是应该是:

Query172031345640518702567_1334079878875({...

我不知道此服务是否在您的控制之下,您可以更改它,还是只需要在URL中添加一些参数(请查看手册).

I don't know if this service is under your control and you can changed it, or you just need to add some params to the URL (check the manual).

此外,响应的内容类型应为application/javascript,而不是text/json.

Also the content type of the response should be application/javascript, not text/json.

这篇关于为什么此JSONP供稿会抛出“意外令牌"?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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