[英]Uncaught SyntaxError: Unexpected token <
I try to access the ORCID API through JavaScript. 我尝试通过JavaScript访问ORCID API 。 I use JSONPfor the cross domain call but get this error: 我使用JSONP进行跨域调用但得到此错误:
Uncaught SyntaxError: Unexpected token < 未捕获的SyntaxError:意外的令牌<
Bellow is the code I use: 贝娄是我使用的代码:
<html >
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$.ajax({
type: 'GET',
url:'http://pub.orcid.org/0000-0002-5426-4031/orcid-bio',
dataType: 'jsonp'
}).done(function(res){alert("sucess")}).
fail(function(res){alert("failed"); console.log(res)}).
always(function(res){alert("complete")});
});
</script>
</head>
<body>
</body>
</html>
According to this page the service will only return JSON if you explicitly request it via the appropriate Accept
header. 根据此页面 ,如果您通过相应的Accept
标头明确请求,该服务将仅返回JSON。
Accept: application/orcid+json
This will tell the server to produce JSON output, it will not automatically enable JSONP, which doesn't seem to be supported by ORCID. 这将告诉服务器生成JSON输出,它不会自动启用JSONP,这似乎不受ORCID支持。
There's a request to add JSONP on their support site . 有人要求在他们的支持网站上添加JSONP 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.