Advertisement
jumpy83

ajax.php

Apr 23rd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3.  
  4. <head>
  5. <title>Esempio ajax | Your Inspiration Web</title>
  6. <link href="screen.css" rel="stylesheet" type="text/css" />
  7.  
  8. <script type="text/javascript" src="jquery-1.3.2.js"></script> <!-- La versione potrebbe essere differente -->
  9. <script type="text/javascript">
  10.  
  11. $(document).ready(function() {
  12.  
  13. $("#input_form").submit(function(){
  14. var nome = $("#nome").attr('value');
  15. var cognome = $("#cognome").attr('value');
  16. var datanascita = $("#datanascita").attr('value');
  17.  
  18. $.ajax({
  19. url: 'result.php',
  20. type: "POST",
  21. data: "nome="+nome+"&cognome="+cognome+"&datanascita="+datanascita,
  22. success: function(data) {
  23. $("div#result2").html(data);
  24. }
  25.  
  26. });
  27.  
  28. return false;
  29. });
  30.  
  31. });
  32. </script>
  33. <script type="text/javascript" src="clone-form-td.js"></script>
  34. </head>
  35.  
  36. <body>
  37.  
  38. <div id="container">
  39. <h1>Esempio di utilizzo di Ajax</h1>
  40.  
  41. <h2>Inserisci i tuoi dati nei campi sottostanti</h2>
  42.  
  43. <h3>Sotto il form visualizzerai la frase senza che vi sia stato un refresh o la richiesta di caricamento di una nuova pagina</h3>
  44. <form id="input_form" action="?">
  45. <div id="entry1" class="clonedInput">
  46. Inserisci il nome:<br />
  47. <input type="text" name="nome" id="nome"/><br /><br />
  48. Inserisci il cognome:<br />
  49. <input type="text" name="cognome" id="cognome"/><br/ ><br/ >
  50. <label>Data di nascita</label> <br/>
  51. <input type="text" name="datanascita" placeholder="GG/MM/AAAA" id="datanascita" /> <br />
  52. </div>
  53. <input type="button" id="btnAdd" name="aggiungicomp" value="aggiungicomp" /> <br />
  54. <input type="submit" value="invia">
  55.  
  56. <div class="row components"></div>
  57. </form><br /><br />
  58. <div id="result2"></div>
  59. </div>
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement