I try to access the ORCID API through JavaScript. I use JSONPfor the cross domain call but get this error:
Uncaught SyntaxError: Unexpected token <
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: 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.