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


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

Re: php e ajax (elementare)

From Alessandro Pellizzari <shuriken@amiran.it>
Newsgroups it.comp.www.php
Subject Re: php e ajax (elementare)
Date 2021-10-24 10:02 +0100
Message-ID <itklp4Fatr6U1@mid.individual.net> (permalink)
References <skj7co$13sf$1@gioia.aioe.org>

Show all headers | View raw


On 18/10/2021 08:23, cb wrote:

> 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)

Ti consiglierei allora di lasciar perdere quel tutorial e quelli simili,
a meno che tu non deva supportare Internet Explorer per qualche motivo.

I browser si sono un po' evoluti rispetto a 10-15 anni fa.

Il modo "moderno" di fare quello che stai facendo รจ simile a questo:

<html>
<head></head>
<body>
  <div>
    <span id="dataGiorno">
       <form action="">
          <input type="button" id="btnData" value="click">
       </form>
    </span>
  </div>
  <script>
    document.getElementById('btnData')
      .addEventListener(
        'click',
        e => {
          e.preventDefault()
          fetch('lista.php')
            .then(res => res.text())
            .then(text => {
              document.getElementById('dataGiorno').innerHTML = text
            })
        },
      )
  </script>
</body>
</html>

Back to it.comp.www.php | Previous | NextPrevious in thread | Next 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