Get jQuery value into PHP Code

Get jQuery value into PHP Code

I have some data assigned in jQuery code that I need to send over to my PHP script and I m not quite sure how to do it.


I have a main page "benefit.htm" which calls a JavaScript function "getApplicantInfo()" defined in the source file "applicant_info.js". The get Applicant function then calls "selectBenefit.js" and tries to pass the value

"$(#ss_id_other").val()" to the "selectBenefit.js" file as the vaaribale "ss_num" within that file. How can this be accomplished?


Source code snippets are included

  1. <!-- file: "benefits.htm" -->
  2. ?<!DOCTYPE html>
    <html>
  3. <head>
    <title>Benefit Processing Page Social</title>
         <meta charset = "utf-8">
                 <link rel = "stylesheet" type = "text/css" href = "css_files/divapplist.css">
  4. <script src="js_files/jquery-1.11.1.min.js"></script>
  5.                 <script type = "text/javascript" src = "js_files/selectBenefit.js"></script>
  6.                 <script type = "text/javascript" src = "js_files/applicant_info.js"></script>
  7. </head>
  8. <table border="0" cellpadding="10" cellspacing="1" width="900" class="tblListForm">
    <tr class="listheader">
    <td></td>
    <td>Social Security No.</td>
    <td>Last Name</td>
    <td>Other Name(s)</td>
    <td>Date of Birth</td>
    <td>Benefit Type</td>
  9. </tr>

  10.   <tr >
    <td><input type="radio" name="arr_bnft_records"
     value="47"
     data-app-id="37"
     data-benefit-type="Funeral Grant"
     data-ss-id-other="33333"
     data-father-weeks=""
     data-funeral-qual=""
     data-last-name="Lee"
     data-other-names="Brenda"
     data-dob="1965-04-04"
     data-sex="F"
     
    ></td>
    <td>33333</td>
    <td>Lee</td>
    <td>Brenda</td>
    <td>1965-04-04</td>
    <td>Funeral Grant</td>
  11. </tr>
  12.  
  13. <tr class="listheader">
    <td colspan="6"><input type="button" id = "submit_btn2" value ="Select" onclick= "getApplicantInfo()"  /></td>
    </tr>
    </table>
  14. // file: applicant_info.js
  15. function getApplicantInfo()
    {  
     
  16.   $("#divMainBenefitsProcessing").slideDown();

  17. $.ajax({
     cache: false,
     url: 'selectedBenefit.php',
     type: 'GET',
     cache: false,
     success: function(response) {
    console.log(response);
  18.  $("#divMainBenefitsProcessing").html(response);
      
      
      $("#divMainBenefitsProcessing").slideDown();
  19. var radioButton = $("input[name='arr_bnft_records']:checked");
               
                if (radioButton == null || radioButton.length < 1)
                    alert("Please select a benefit record for processing.");
                else
         {
         $("#ss_id_other").val(radioButton.attr("data-ss-id-other"));
                    $.post('selectedBenefit.php',{ss_num: $("#ss_id_other").val()});
  20.     }
  21.  },
     
     beforeSend: function(){
  22.  },
     error: function(e) {
    console.log(e.message);
     }
    });
    }
  23. //file: selectBenefit.php
  24. <?php
  25. echo "value: " .$_POST['ss_num'] . "<br/>";
    ?>