Advertisement
LucianoCharles2017

ajax_simple

May 10th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.   <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.   <title>Document</title>
  8.  
  9.   <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  10.   <script>
  11.       function clica(){
  12.             $.post('http://localhost/simpleormteam/teste.php',{var :'teste'},function(data){              
  13.                 $('#resultado').append(data);
  14.             },'html');
  15.       }
  16.   </script>
  17. </head>
  18. <body>
  19.  
  20.   <div id="resultado"></div>
  21.  
  22.   <?php
  23.     if(isset($_POST['var'])){
  24.       $var = $_POST['var'];
  25.       echo '<p style="background-color:red">' .$var.  '</p>';
  26.       exit();
  27.     }
  28.   ?>
  29.  
  30.     <button onclick="clica();">Clica</button>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement