Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1.    
  2. <!-- Html employment row -->
  3. <div class="row employment_block">
  4.    
  5.         <div class="col-md-3">
  6.             <input type="text" name="job_title[]" placeholder="Job title">
  7.         </div>
  8.  
  9.         <div class="col-md-3">
  10.             <input type="text" name="job_duration[]" placeholder="Duration (i.e. 3 months / 1 year)">
  11.         </div>
  12.        
  13.         <div class="col-md-3">
  14.             <input type="text" name="job_location[]" placeholder="Country">
  15.         </div>
  16.         <div class="col-md-3 text-center">
  17.         <button href="#" class="able_btn m-0 w-100 disabled" disabled aria-disabled="true" style="opacity:0.5"> remove </button>
  18.         </div>
  19.  
  20.     </div>
  21.  
  22.  
  23. <!-- AJAX on form submit -->
  24. $(document).ready(function(){
  25.  
  26. $(".account_cv_update_form").submit(function(evt){  
  27. evt.preventDefault();
  28.  
  29.       var formData = new FormData($(this)[0]);
  30.    $.ajax({
  31.        url: 'handlers/cv_update.php',
  32.        type: 'POST',
  33.        data: formData,
  34.        async: false,
  35.        cache:false,
  36.        contentType: false,
  37.        processData: false,
  38.        dataType: "json",
  39.     success: function (response) {
  40.  
  41.       switch(response.message){  
  42.         case 'success': success();
  43.         break;
  44.         case 'error': error();
  45.         break;
  46.  
  47.       }
  48.  
  49.     }
  50.   });
  51. return false;
  52. });
  53.  
  54. });
  55.  
  56.  
  57. <!-- PHP handler code / json encoding array-->
  58.  
  59. $job_title = $_POST['job_title'];
  60. $job_duration = $_POST['job_duration'];
  61. $job_location = $_POST['job_location'];
  62.  
  63. $json_data = array(
  64.         'job_title' => $job_title,
  65.         'job_location' => $job_location,
  66.         'job_duration' => $job_duration );
  67.  
  68. $cv_data = json_encode($json_data);
  69.  
  70. echo json_encode($response);
  71. exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement