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


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

Re: php e ajax (elementare)

From pippo <pippo@invalid.it>
Newsgroups it.comp.www.php
Subject Re: php e ajax (elementare)
Date 2021-10-24 13:00 +0200
Organization Aioe.org NNTP Server
Message-ID <sl3edj$1pr4$1@gioia.aioe.org> (permalink)
References <skj7co$13sf$1@gioia.aioe.org> <itklp4Fatr6U1@mid.individual.net>

Show all headers | View raw


Alessandro Pellizzari ha detto questo domenica :
> 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>
>

Ehilà!
Un frammento così era proprio quello che cercavo per *fetch*.
Niente prove da fare, tutto già sistemato. Non lo testo neanche, 
suppongo che funzioni senza problemi.

Era un po' che non ti vedevo. Grazie tante.

Se non erro una chiamata con fetch non è l'esatto equivalente di una 
chiama ajax "tradizionale"

Ciao.

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