Ajax is not updating text(.txt)

Asked

Viewed 34 times

1

I made the ajax connection (copied and even pasted) to introduce a text in the div . txt then, I changed the text and saved, but it still shows the text before the modification

<script>
    function corpo(titulo, texto) {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("titulo").innerHTML = titulo;
            document.getElementById("corpo").innerHTML =
            this.responseText;
        }
      };
      xhttp.open("GET", texto, true);
      xhttp.send();
    }
</script>
  • Have you made sure that the HTTP response has the updated or old text? If you have the old one, the problem is not in JS and the question will be impossible to answer.

  • yes, it is the updated that ta in the same and with the same name(I did not understand very well the question, but, I opened the same file that was working and modified saving later, deleting the old and putting the new I imagine and..e) if it is wrong, dsclpa :b I’m half dumb memo

  • Analyze the request using your browser’s developer tools.

  • How you saved this altered text?

  • basically saving in the editor q the site itself has. I did not understand what Anderson said, so I took a print. The site is one of those free and tals subdomain, I made a print and if you want the site: https://prntscr.com/libg1i http://estudos.epizy.com/

  • This code of yours does nothing more than pull the contents of a .txt. file If you want to save something, you would have to use backend code (e.g. PHP) to rewrite the file. txt.

  • yes, but I modified the txt itself to change the html content type, I modified the txt but it’s like I haven’t changed

  • https://prntscr.com/lic93o here shows what is saved, and what appears (selected)

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.