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

203
Visualizações
How would get/edit data from a text file?

I have a specific website where i would like to see how many views a certain page gets, with a text file being edited every time a person clicks on the page. I've tried doing this myself but it did not work out, I am not sure if i have done anything wrong here myself since i am still new to javascript.

var viewC = FileReader.readAsText('./views.txt');

var views = viewC + 1
var viewFile = " " + views +" ";

function download(content, fileName, contentType) {
    var a = document.createElement("a");
    var file = new Blob([content], {type: contentType});
    a.href = URL.createObjectURL(file);
    a.download = fileName;
    a.click();
}
download(viewFile, 'views.txt', 'text/plain');

For a more detailed description of what i would like to happen : "When the user goes to the page, the code will run and add a new value to the text file. The new value is +1 of the old value that is there." Expected result -
TXT file before
TXT file after a person views it 1
TXT file after the second view 1 2
Or if it is possible to remove the old number and add the new number

about 4 years ago · Juan Pablo Isaza
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