title: Better solution as my ajax post?
body: <p>I have the following php code:</p>
  
  <pre><code>                            &lt;tr&gt;
                              &lt;td class="vacancyID"&gt;
                                  &lt;?php echo $vacancyID; ?&gt;
                              &lt;/td&gt;
                              &lt;td class="roleLongTitle"&gt;
                                  &lt;?php echo $roleLongTitle; ?&gt;
                              &lt;/td&gt;
                              &lt;td class="roleRequirements"&gt;
                                  &lt;?php echo $roleRequirements; ?&gt;
                              &lt;/td&gt;
                              &lt;td class="roleResponsibilities"&gt;
                                  &lt;?php echo $roleResponsibilities; ?&gt;
                              &lt;/td&gt;
                              &lt;td class="roleQualifications"&gt;
                                  &lt;?php echo $roleQualifications; ?&gt;
                              &lt;/td&gt;
                              &lt;td class="closeDate"&gt;
                                  &lt;?php
                                      //Convert the mySQL date to PHP date
                                      echo convertToDate($closeDate);
                                  ?&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
  </code></pre>
  
  <p>And the following jquery code:</p>
  
  <pre><code>$(document).ready(function(){
  var btn = $('a.btn-primary'); 
  var closeDate = $('td.closeDate');
  var applyBtn = $('&lt;input type="button" value=" Apply " class="toggleButton" /&gt;');
  //var applyLnk = $('&lt;a href="index.php" class="btn btn-primary" role="button"&gt;Apply&lt;/a&gt;');
  
  //Rmove a link
  btn.remove();
  
  //Add button
  applyBtn.insertAfter(closeDate);
  //applyBtn.appendTo(closeDate);
    //applyLnk.insertAfter(closeDate);
  
  $('.toggleButton').click(function(){
      var obj = $(this).closest('tr');
      var data = {
              vacancyID: obj.find('td.vacancyID').text(),
              closeDate: obj.find('td.closeDate').text(),
              roleLongTitle: obj.find('td.roleLongTitle').text(),
              roleRequirements: obj.find('td.roleRequirements').text(),
              roleResponsibilities: obj.find('td.roleResponsibilities').text(),
              roleQualifications: obj.find('td.roleQualifications').text(),
          }
  
           //Post the data to the page
          $.ajax({
               type: 'POST',
               url: 'vacancy.php',
               data: data,
               success: function(data){
                  window.location.assign("applyForVacancy.php");
               }
          });
          //console.log(data);
      });
  
  });
  </code></pre>
  
  <p>Is there any way for me to make this better?  I have tried many option and this one is the only one that's working and that can get access to those posted values based on the button I clicked.</p>