【发布时间】:2026-01-14 01:20:05
【问题描述】:
我正在尝试使用某种服务来检查代理。他们有一个简单的 API,可以从中返回 JSON。我想在我的服务器上获取这个 JSON。
无论我做什么,我都会收到 CORS 请求问题或 SyntaxError: missing ; before statement 消息。
这是我的代码:
<h1>Test Page</h1>
<a href="#" onclick="checkProxy()">Test Button</a>
<script>
function checkProxy() {
console.log("Checking...");
$.ajax({
url: 'http://api.ip2proxy.com/?ip=105.159.246.30&key=demo',
dataType: 'jsonp',
success: function(data){
console.log(data);
}
});
}
单击我的“按钮”会调用该函数,该函数会返回上述语法错误。将数据类型更改为 JSON 会给我一个 CORS 错误。
奇怪的是,当我使用不同的 URL(我在另一个 * 线程中找到的示例:http://www.locationbox.com.tr/locationbox/services?Key=3430000202000191008400080609030X20201090060050260003069&Cmd=IlList)时,它会很好地记录数据。
【问题讨论】:
-
那么数据可能不打算公开共享。你检查过数据源的API吗?
标签: javascript json cors jsonp