我正在使用代码笔上的黑暗天空 API。https://codepen.io/ashan_zeroxster/pen/MpxVOv?editors=0010 当我尝试从 DARKSKY API 获取 JSON 数据时,我收到 XMLHTTPREQUEST 错误。我的代码
$(document).ready(function(){
var api = https://api.darksky.net/forecast/a18d80cbf99f8930c6a140bf8e722630/";
var long = "";
var lat = "";
var url = "";
navigator.geolocation.getCurrentPosition(function (position){
var long = position.coords.longitude;
var lat = position.coords.latitude;
var url = api + long + "," + lat;
$.getJSON(url, function(data){
document.write(data);
});
});
});