Advertisement
fcamuso

Corso recupero Javascript - video 14

Jun 11th, 2023
1,234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.   <title>Document</title>
  8. </head>
  9. <body>
  10.   <p id="p1"></p>
  11.  
  12.   <select>
  13.     <option >a</option>
  14.     <option >b</option>
  15.     <option >c</option>
  16.     <option >d</option>
  17.   </select>
  18.  
  19.   <button id="btn">CALCOLA</button>
  20.   <script>
  21.    function funzione() {
  22.      let ris = 0;
  23.      for (let i=0; i<1000000000; i++){
  24.        ris += Math.sqrt(i*Math.sin(i)*Math.sin(i));
  25.      }
  26.      return ris;
  27.    }
  28.  
  29.    async function funzione_fetch() {
  30.     const risposta_server = await fetch("https://www.camuso.it/test/elabora_con_ritardo.php");
  31.     //alert("attesa terminata!");
  32.     const dati = await risposta_server.text();
  33.     document.getElementById("p1").innerText=dati;
  34.    
  35.      
  36.    }
  37.  
  38.    //document.getElementById("btn").addEventListener("click", funzione_fetch);
  39.    funzione_fetch();
  40.    alert("sono ritornato subito dalla funzione async anche se non terminata");
  41.  
  42.    
  43.    
  44.    
  45.  
  46.   </script>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement