Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
I want to link with the api

I want to link with the api but this link (https://api.fm-track.com/object-coordinates-stream.json?version=2&api_key=1g6F9NvaKY4jsnmrLqmzxILIMhTpncwr) every time I try to link it with my site

I can't why

this code

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />


    <link href="https://fonts.googleapis.com/css?family=Dosis:400,700" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
      $(document).ready(function() {
        $.ajax({
          url: "https://api.fm-track.com/object-coordinates-stream.json?version=2&api_key=1g6F9NvaKY4jsnmrLqmzxILIMhTpncwr",
          type: "GET",
          success: function(result) {
            console.log(result);
          },
          error: function(error) {
            console.log(error);
          }
        });
      });
    </script>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your API actually return text/event-stream which is is the official media type for Server Sent Events (SSE)

You can accept SSE like this:

      const evtSource = new EventSource("https://api.fm-track.com/object-coordinates-stream.json?version=2&api_key=1g6F9NvaKY4jsnmrLqmzxILIMhTpncwr");
evtSource.onmessage = function(event) {
  const newElement = document.createElement("li");
  const eventList = document.getElementById("list");
    const data = JSON.parse(event.data);
    console.log(data);
  newElement.textContent = "message: " + data['object_id'];
  eventList.appendChild(newElement);
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />


    <link href="https://fonts.googleapis.com/css?family=Dosis:400,700" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  </head>
  <body>
    <ul id="list"></ul>
  </body>
</html>

For more details:

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

https://www.w3schools.com/html/html5_serversentevents.asp

https://stackoverflow.com/a/52099962/11250643

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda