nstruth2

Working Retrieve.php Page

Jan 15th, 2024 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.56 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Insert data in MySQL database using Ajax</title>
  5.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  6.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  7.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. </head>
  9. <body>
  10. <div id="targetLegit2"> </div>
  11. <script>
  12. $(document).ready(function() {
  13. $('#butLoad').on('click', function() {
  14. let identification = $('#identification').val();
  15.  
  16.     $.ajax({
  17.         url:  "save.php",
  18.         type: "POST",
  19.         data: {
  20.             identification: identification
  21.         },
  22.         cache: false,
  23.         success: function(dataResult){
  24.             dataResult = JSON.parse(dataResult);
  25.             if(dataResult.statusCode==200){  
  26.                 $('#targetLegit2').load('showDescription.php', {identification: identification});
  27.             }
  28.             else if(dataResult.statusCode==201){
  29.                 alert("Error occured !");
  30.             }
  31.            
  32.        
  33.     }
  34.  
  35.     });
  36. });
  37.  });  
  38. </script>
  39. <?php
  40.    error_reporting(E_ALL);
  41.    ini_set('display_errors', 1);
  42.                echo <<<EOT
  43.        <div class="form-group">
  44.             <label for="id">Identification #:</label>
  45.             <input type="number" class="form-control" id="identification" placeholder="id" name="identification">
  46.         </div>
  47.         <input type="button" name="load" class="btn btn-primary btn-lg" value="Load From Database" id="butLoad">
  48.         EOT;
  49. ?>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment