title: My PHP variable is not receiving data from my AJAX (WordPress)
body: <p>I am having problems with my PHP variable not receiving the data I passed using AJAX.</p>
  <p>Here is my script:</p>
  <pre><code>   jQuery('.ch-user &gt; div .ch-function button').click(function(){ 
          var userID = jQuery(this).attr('data-user-id'); // User ID
          var userName = jQuery(this).attr('data-user-name'); // User display name
          var userProgress = jQuery(this).attr('data-user-progress'); // Challenge progress in percentage
          var userCHL = jQuery(this).attr('data-user-chl'); // No. of challenges completed
  
          jQuery('.popup-details').attr('data-id', userID);
          jQuery('.popup-details .pd-name').text(userName);
          jQuery('.popup-details .pd-progress .ch-progress-number').text(userCHL + ' / 30');
          jQuery('.popup-details .pd-progress .ch-progress').attr('style', 'max-width:' + userProgress + '%;');
          jQuery('.popup-details').addClass('open');
          console.log(userID);
          
          jQuery.ajax({
              type : 'post',
              dataType : 'json',
              url : myAjax.ajaxurl,
              data : {action: 'chu_plugin_settings_page', user_id : userID, user_name : userName},
              success: function(response) {
                  console.log('Challenge Complete!');  
                  jQuery('#ch-users-display').html(response.user_id);
              }
          })
  
      });
  </code></pre>
  <p>And here is where the data values should be used:</p>
  <pre><code>                    $userCHID = $_POST['user_id'];
                      $userCHNAME = $_POST['user_name'];
                      $chUserMETA = get_user_meta($userCHID, 'challenge', true);
                      $chCOMP = (empty($chUserMETA)) ? 0 : count($chUserMETA);
                      $chPUB = wp_count_posts( 'challenge' )-&gt;publish;
                      $chLEFT = ($chCOMP == 0) ? $chPUB - 0 : $chPUB - $chCOMP;
                      if (!empty($userCHID)) :
                          $args = array(
                              'post_type' =&gt; 'challenge',
                              'post_status' =&gt; 'publish',
                              'posts_per_page' =&gt; $chLeft, 
                              'meta_key' =&gt; 'day',
                              'orderby' =&gt; 'meta_value', 
                              'order' =&gt; 'ASC', 
                          ); $loop = new WP_Query( $args ); 
                          if ( $loop-&gt;have_posts() ) :
                              while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); 
                                  $badgeIcon = ''; 
                                  $dayfield = get_field('day');
                                  $day = (!empty(get_field('day'))) ? 'Day '.$dayfield : '';
                                  $challengeName = get_the_title();
                                  echo (!empty($dayfield)) ? '
                                  &lt;div class=&quot;pd-challenge&quot;&gt;
                                      &lt;div class=&quot;ch-day&quot;&gt;'.$day.'&lt;/div&gt;
                                      &lt;div class=&quot;ch-name&quot;&gt;'.$challengeName.'&lt;/div&gt;
                                      &lt;div class=&quot;ch-date&quot;&gt;Date Completed: MM/DD/YYYY&lt;/div&gt;
                                  &lt;/div&gt;
                                  ' : '';
                              endwhile; wp_reset_query(); 
                          else :
                              echo 'No challenges yet';
                          endif;
                      else :
                          echo '&lt;div&gt;Cannot find user ID...&lt;/div&gt;';
                          echo $chPUB.' - '.$chCOMP.' = '.$chLEFT.' [user_id : '.$userCHID.', ch_user_meta : '.$chUserMETA[0].', user_name ; '.$userCHNAME.']';
                      endif;
  </code></pre>
  <p>I needed the <strong>user_id</strong> to get the details and output the data in the user's user-meta.</p>
  <p>So the script works perfectly fine, so it confuses me why it doesn't work on the PHP side as the <strong>$_POST['user_id']</strong> and <strong>$_POST['user_name']</strong> are empty.</p>