CESIUM ERROR "ReferenceError: $ is not defined " (writing in SANDCASTLE)

CESIUM ERROR "ReferenceError: $ is not defined " (writing in SANDCASTLE)

$.ajax({
  type: "GET",
  dataType: "json",
  url: "https://reqres.in/api/unknown/2",
  success: function(data){
    console.log(data)
  }
});

我试过插入:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

但cesium不像普通平台那样工作

Cesium的“Sandcastle”测试环境没有包含JQuery的手段。相反,你可以使用 Cesium 自己的辅助函数来做这样的事情,比如 Cesium.Resource.fetchJson.

例如:Live Sandcastle Demo

var viewer = new Cesium.Viewer("cesiumContainer");

Cesium.Resource.fetchJson({
  url: "https://reqres.in/api/unknown/2"
}).then(data => {
  console.log(JSON.stringify(data, null, '    '));
});