Reputation: 1
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>
Upvotes: 0
Views: 1386
Reputation: 308061
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.
There's a request to add JSONP on their support site.
Upvotes: 2