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

202
Visualizações
Dynamically change text on HTML page from the С program

I have a web server (thttpd), and I want to periodically change the text on the HTML page depending on the data from my application C. I think to write a simple .txt file in the C application and periodically read it on a web server and change data on the HTML page. But I don't know how to do it. Maybe there are more correct and simple versions, how to do it?

ANSWER: I make this by using fetch(). This code read text from file dynamic_data.txt and change element with id="ispr_1" with this text every 3sec.

<script>

    const ispr = document.getElementById("ispr_1");

    var myFile = 'dynamic_data.txt';
    async function getUsers() {
        var response = await fetch(myFile, {cache: "reload"});
        if (response.ok) {
            var data = await response.text();
            ispr.textContent = data;
            return data;
        } else {
            alert('error', response.status);
        }
    }

    var intervalId = setInterval(getUsers, 3000);
</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Put your C file output somewhere in your server, and look at https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

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