Hello my friends. I'm trying to understand Ajax. Namely, with the sending data to the server. I have the form

Hello my friends. I'm trying to understand Ajax. Namely, with the sending data to the server. I have the form

Hello my friends. I'm trying to understand Ajax. Namely, with the sending data to the server.
I have the form, and i need to send to db with ajax

  1. <form  id = "send_form">
  2.             <table>
  3.                 <thead id=heading>
  4.                 <tr>
  5.                     <th>Name
  6.                     <th>Age
  7.                     <th>Salary
  8.                 </tr>
  9.                 </thead>
  10.                 <tbody id=records

  11.                 <tr>
  12.                     <td>
  13.                         <div class="col-sm-3"><textarea id="emp_name" name="emp_name_n" cols="10" rows="1"></textarea>
  14.                         </div>
  15.                     </td>
  16.                     <td>
  17.                         <div class="col-sm-3"><textarea id="emp_age" name="emp_age_n" cols="10" rows="1"></textarea>
  18.                         </div>
  19.                     </td>
  20.                     <td>
  21.                         <div class="col-sm-3"><textarea id="emp_salary" name="emp_salary_n" cols="10" rows="1"></textarea>
  22.                         </div>
  23.                     </td>
  24.                     <td>
  25.                         <input type="image" id="emp_image" name="emp_image" width="100" height="110">
  26.                     </td>
  27.                     <td>
  28.                         <input type="image" id="emp_image2" name="emp_image2" width="100" height="110">
  29.                     </td>
  30.                 </tr>
  31.                 </tbody>
  32.             </table>
  33. <input type="submit" class="btn btn-primary"  id="send_data" name="send_data" value="Send">
  34. </div>
  35. </form>


My PHP
  1. <?php
  2.     $mo_number =  $_POST['emp_name_n'];
  3.     $filter_name = $_POST['emp_age_n'];
  4.     $quantity =  $_POST['emp_salary_n'];
  5.     include_once("db_connect.php");
  6.     $sql = "INSERT INTO  sender (employee_name_s, employee_age_s, employee_salary_s)
  7.     VALUE ('$mo_number', '$filter_name', '$quantity')";
  8.     $query = mysqli_query($conn,$sql);
  9. ?>
My Jquery try to do with this
Help plz

  1. $(document).ready(function(){
  2. // code to get all records from table via select box
  3. $("#send_data").click(function() {
  4. var name = ('#emp_name').val();
  5. var age = ('#emp_age').val();
  6. var salary = ('#emp_salary').val();
  7. $.ajax({
  8.   url:"sender.php",
  9.   method:"POST",
  10.   data: {emp_name_s:name, emp_age_sage:age, emp_salary_s:salary:},
  11.   success:function(data){

  12. }
  13.                 });
  14.            }
  15.       });
  16.  });