使用JSONP找不到JSON_CALLBACK

tho*_*ter 6 jsonp angularjs

我正在尝试使用以下代码获取JSONP响应...

$http.jsonp('http://example.com:8888/?callback=JSON_CALLBACK').success( function( response )
{
    console.dir( response );
});
Run Code Online (Sandbox Code Playgroud)

http://example.com:8888/?callback=JSON_CALLBACK通过node.js返回以下内容

JSON_CALLBACK({date:'2013-05-15T08:53:51.747Z'});

标题是在node.js中设置的,就像这样....

res.writeHead(200, {'Content-Type': 'application/json'});
Run Code Online (Sandbox Code Playgroud)

但我在Chrome控制台中遇到的错误是......

Uncaught ReferenceError: JSON_CALLBACK is not defined 
Run Code Online (Sandbox Code Playgroud)

但是,奇怪的是,如果我创建window.JSON_CALLBACK(response)它将运行它的功能.但我认为成功意味着代表我这样做.

And*_*ves 2

您的内容类型标头不正确。

application/json如果您返回的是纯 JSON,请使用。JSONP 是 Javascript,所以你应该使用application/javascript