Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Insert data in MySQL database using Ajax</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <div id="targetLegit2"> </div>
- <script>
- $(document).ready(function() {
- $('#butLoad').on('click', function() {
- let identification = $('#identification').val();
- $.ajax({
- url: "save.php",
- type: "POST",
- data: {
- identification: identification
- },
- cache: false,
- success: function(dataResult){
- dataResult = JSON.parse(dataResult);
- if(dataResult.statusCode==200){
- $('#targetLegit2').load('showDescription.php', {identification: identification});
- }
- else if(dataResult.statusCode==201){
- alert("Error occured !");
- }
- }
- });
- });
- });
- </script>
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- echo <<<EOT
- <div class="form-group">
- <label for="id">Identification #:</label>
- <input type="number" class="form-control" id="identification" placeholder="id" name="identification">
- </div>
- <input type="button" name="load" class="btn btn-primary btn-lg" value="Load From Database" id="butLoad">
- EOT;
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment