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

i tried insesrt:

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

but cesium not works like ordinary platfroms

Liam
  • 27,717
  • 28
  • 128
  • 190
  • Your code works fine for me. You need to make sure that the ` – Peter B Dec 23 '21 at 12:04
  • `

    Loading...

    ` this is all what CESIUM provide in HTML body & CSS. Where should i put
    – user17603839 Dec 23 '21 at 12:48
  • are you trying in Sandcastle? – ZhefengJin Dec 23 '21 at 12:56
  • 1
    I don't know Cesium, but a quick search told me that it has a [loadJson](https://cesium.com/downloads/cesiumjs/releases/b29/Documentation/loadJson.html) feature that will do just about the same as `$.ajax`, without the trouble of having to get jQuery working. – Peter B Dec 23 '21 at 12:56
  • yes, im trying in Sandcastle – user17603839 Dec 23 '21 at 13:05
  • Does this answer your question? [JQuery - $ is not defined](https://stackoverflow.com/questions/2194992/jquery-is-not-defined) – Liam Dec 24 '21 at 09:06
  • no, im still struggling :/ @Liam The problem is something related about Sandcastle, because for example in replit.com IDE works everything fine. So it is my lack of competence about Sandcastle – user17603839 Dec 24 '21 at 12:51
  • It would probably help if you included the [tag:sandcastle] tag then – Liam Dec 24 '21 at 13:24
  • Is there a reason you don't just do [what is suggest here?](https://stackoverflow.com/questions/70461880/cesium-error-referenceerror-is-not-defined-writing-in-sandcastle?noredirect=1#comment124556306_70461880). In 2021/2022 you really don't need jquery – Liam Dec 24 '21 at 13:25
  • Or even use the native [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started). without using an libraries at all – Liam Dec 24 '21 at 13:26
  • Try to give more details on what you wish to achieve. – ABDULLOKH MUKHAMMADJONOV Jan 01 '22 at 16:34
  • im trying to achieve drones position (longitude,latitude,height) in real time and use these coordinates to animate flight. – user17603839 Jan 02 '22 at 14:41

1 Answers1

0

Cesium's "Sandcastle" test environment does not include a means to include JQuery. Instead, you can use Cesium's own helper functions for things like this, such as Cesium.Resource.fetchJson.

For example: 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, '    '));
});
emackey
  • 11,818
  • 2
  • 38
  • 58