JavaScript를 통해 ORCID API에 액세스하려고합니다. 나는 JSONPfor에게 크로스 도메인 호출을 사용하지만,이 오류가 발생합니다 :잡히지 않은 SyntaxError : 예기치 않은 토큰 <
Uncaught SyntaxError: Unexpected token <
우는 소리가 내가 사용하는 코드입니다 :
<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>
=> – sdespont
여기에서 사용하는 URL은 JSON이 아닌 XML을 반환합니다. –
서버에서 JSONP를 지원해야합니다. JSONP가 자동으로 발생하지 않는다고 기대하는 jQuery에 대해 알려줍니다. –