gpt4 book ai didi

javascript - Requirejs jsonp 和未捕获的语法错误 : Unexpected token :

转载 作者:行者123 更新时间:2023-11-29 15:33:19 25 4
gpt4 key购买 nike

我正在测试这个 JSON 提要 https://www.unisport.dk/api/sample/像这样使用 requirejs jsonp

require(['https://www.unisport.dk/api/sample/?callback=define'],
function ( data ) {
console.log( typeof data );
}
);

如此处所述http://requirejs.org/docs/api.html#jsonp .我用过https://jsonformatter.curiousconcept.com/验证提要。但是这个代码片段抛出以下异常

Uncaught SyntaxError: Unexpected token :

我的 HTML 看起来像这样

<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="css/normalize.min.css">
<link rel="stylesheet" href="css/main.css">

<script src="scripts/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="scripts/vendor/jquery-1.11.2.min.js"><\/script>')</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.min.js" data-main="scripts/main"></script>

</body>
</html>

jQuery 没有在任何地方使用,除了上面发布的内容之外没有其他代码。

最佳答案

JSONP 是远程服务器必须明确支持的东西,看起来您指向的服务器不支持。

它返回纯 JSON,当作为脚本进行评估时,它将抛出您遇到的错误。

关于javascript - Requirejs jsonp 和未捕获的语法错误 : Unexpected token :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32317991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com