【发布时间】:2013-07-30 14:18:26
【问题描述】:
我不知道这个错误是怎么回事,每个请求都有一个唯一的字符串。我请求的 jsonP 是一个 jsonP 代理,据我所知,它已按应有的方式进行配置。
var url = 'https://phpproxy-dev.herokuapp.com/?url=http://personer.eniro.se/resultat/'+who+'/'+where+'&callback=?';
$.getJSON(url, function (data) {
//console.log(data)
});
回复:
jQuery19107590448246337473_1375193471216({"status":{"http_code":200},"contents":"//an html page wrapped in a json-object, I can't post it because it hangs chrome when I try to push the code button i stackoverflow. "})
我在 https 页面上运行greasemonkey 中的代码。
【问题讨论】:
-
@Spokey 这是 jQuery 为 JSONP 生成的。如您所见,OP 没有使用它。但他们使用
$.getJSON并在URL 中提供callback=? -
@Neal:错误在标题中
-
由于 jQuery 将创建一个具有正确回调名称的函数,我只能想象您以某种方式更改了服务器脚本中的回调名称。
-
您的代码对我有用。 jsfiddle.net/GPD7r。 (使用 jQuery 1.9.1,好像和你的一样)。
-
在这种情况下,您需要弄清楚在您的上下文中什么被视为全局范围。这就是需要定义回调的地方。如果全局上下文不是窗口,您可能无法使用 jQuery 发出此 ajax 请求。
标签: javascript jquery greasemonkey