Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.www.php > #22940

php e ajax (elementare)

From cb <cb@ppt.io.it>
Newsgroups it.comp.www.php
Subject php e ajax (elementare)
Date 2021-10-18 09:23 +0200
Organization Aioe.org NNTP Server
Message-ID <skj7co$13sf$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Chiedo pazienza a tutti, ma sto provando ad usare ajax.
Il mio primo tentativo di chiamare php da una pagina html e' qui sotto
(scopiazzando e modificando l'esempio da w3school e da altri tutorial 
sul web)
Il problema e' che quando clicco ... si ricarica la pagina e basta :-(
Evidentemente mi manca qualcosa di basilare.
Qualcuno ha la pazienza di indicarmelo ?
GRAZIE
----- index.html
<html>
<head></head>
<body>
<div>
    <span id="dataGiorno">
       <form action="">
          <input type='button' onclick='show()' value='cclick'>
       </form>
    </span>
</div>
<script>
function show() {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
       if (this.readyState == 4 && this.status == 200) {
          document.getElementById("dataGiorno").innerHTML = 
this.responseText;
       }
    };
    xhttp.open("GET", "lista.php, true);
    xmlhttp.send();
}
</script>
</body>
</html>
---- lista.php
<?php
echo "<h1>data del giorno</h1>";
?>

Back to it.comp.www.php | Previous | NextNext in thread | Find similar | Unroll thread


Thread

php e ajax (elementare) cb <cb@ppt.io.it> - 2021-10-18 09:23 +0200
  Re: php e ajax (elementare) pippo <pippo@invalid.it> - 2021-10-19 12:25 +0200
    Re: php e ajax (elementare) cb <cb@ppt.io.it> - 2021-10-19 12:53 +0200
      Re: php e ajax (elementare) Leonardo Serni <lserni@gmail.com> - 2021-10-19 23:02 +0200
        Re: php e ajax (elementare) cb <cb@ppt.io.it> - 2021-10-20 08:09 +0200
          Re: php e ajax (elementare) Leonardo Serni <lserni@gmail.com> - 2021-10-20 08:58 +0200
      Re: php e ajax (elementare) pippo <pippo@invalid.it> - 2021-10-21 05:15 +0200
  Re: php e ajax (elementare) Alessandro Pellizzari <shuriken@amiran.it> - 2021-10-24 10:02 +0100
    Re: php e ajax (elementare) pippo <pippo@invalid.it> - 2021-10-24 13:00 +0200
      Re: php e ajax (elementare) Alessandro Pellizzari <shuriken@amiran.it> - 2021-10-24 12:40 +0100

csiph-web