title: AJAX - Getting value of radio button and sending it to PHP
body: <p>I've been having this issue for a while now and I guess I'm stuck. I've been reading on how to use AJAX to send data to a PHP file.</p>
  
  <p>The thing is, I don't really get how to take the value of a radio button in a HTML page and then send that value through AJAX to a PHP file which will then process that value.</p>
  
  <p>So for example:</p>
  
  <p><strong>If I had 2 radio buttons</strong></p>
  
  <pre><code>&lt;input type="radio" name="radio" value="yes"&gt;
  &lt;input type="radio" name="radio" value="no"&gt;
  </code></pre>
  
  <p><em>And I would like to take the value of those radio buttons and send it to my PHP file using AJAX.</em></p>
  
  <p><em>Next I would be able to process those values in PHP.
  How would I make it so that AJAX sends the value of the selected radio button to PHP?</em></p>
  
  <p>Thanks, in advance!</p>
  
  <p>EDIT:</p>
  
  <p>Full code:</p>
  
  <p><strong>HTML File</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function updatePremium() {
          var input1= $("#premium-yes").val();
          var input2= $("#premium-no").val();
          $.post( "upd_premium.php", { input1: input1, input2: input2 } );
      }
  &lt;/script&gt;
  
  &lt;div class="usersRow2"&gt;
      &lt;form action="" method="POST"&gt;&lt;label&gt;Premium:&lt;/label&gt; &lt;p class="text-info-premium"&gt;&lt;?php echo ucwords($premium_check) ?&gt;&lt;i class="icon-star"&gt;&lt;/i&gt;&lt;/p&gt; &lt;div class="controls-premium"&gt;&lt;a href='#' id="edit-premium" class="btn"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt; Edit&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
  $('#edit-premium').click(function() {
   var text = $('.text-info-premium').text();
   var input = $('&lt;input type="radio" name="premium" id="premium-yes" value="yes"&gt;Yes &lt;input type="radio" name="premium" id="premium-no" value="no"&gt;No &lt;div id="premium"&gt;&lt;/div&gt;')
  
   $('.text-info-premium').text('').append(input);
   $('#edit-premium').remove();
   $('&lt;a href="#" id="update-premium" onClick="updatePremium()" class="btn"&gt;Update&lt;/a&gt;').insertAfter('#premium');
  
   $('&lt;i class="fa fa-times" title="Cancel Edit"&gt;&lt;/i&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;').insertAfter('#update-premium');
   $('.fa-times').click(function() {
      location.reload();
   });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP File</strong></p>
  
  <pre><code>if($_POST['input1'] == 'yes') {
      print_r($_POST);
  }
  </code></pre>