Guest User

Codice HTML

a guest
Jan 23rd, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.30 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title></title>
  6. </head>
  7. <body>
  8.     <label for="team">Scegli una squadra:</label>
  9.     <select id="team" name="team">
  10.         <option value="">Effettua una selezione</option>  
  11.         <option value="Milan">Milan</option>  
  12.         <option value="Juventus">Juventus</option>  
  13.         <option value="Cagliari">Cagliari</option>  
  14.         <option value="Roma">Roma</option>
  15.     </select>
  16.     <div id="tabella"></div>
  17.     <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
  18.     <script>
  19.         $(document).on("change", "#team", function() {
  20.             var team = $(this).val();
  21.            
  22.             if (team !== '') {
  23.                 $.ajax({
  24.                     type: "post",
  25.                     url: 'tabelle.php',
  26.                     data: 'team='+JSON.stringify(team),
  27.                     dataType: 'html',
  28.                     success: function(response) {
  29.                         $('#tabella').html(response);
  30.                     },
  31.                     error: function(response) {
  32.                         $('#tabella').html('<br />ERRORE : il server non risponde o lo ha fatto in modo anomalo '+response.responseText);
  33.                     }
  34.                 });
  35.             }
  36.         });
  37.     </script>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment