title: Get AJAX POST Using PHP
body: <p>I have a <code>drpcategory</code> dropdown in a form. I will just paste the dropdown code below;</p>
  
  <pre><code>&lt;div class="form-group"&gt;
       &lt;label&gt;Category&lt;/label&gt;
       &lt;select class="form-control bg-dark btn-dark text-white" id="drpcategory" name="drpcategory" required&gt;
       &lt;?php
            $category = ''.$dir.'/template/post/category.txt';
            $category = file($category, FILE_IGNORE_NEW_LINES);
  
            foreach($category as $category)
            {
                echo "&lt;option value='".$category."'&gt;$category&lt;/option&gt;";
            }
       ?&gt;
       &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then I AJAX <code>post</code> every time I make a selection in the above <code>drpcategory</code> dropdown as below;</p>
  
  <pre><code>&lt;script&gt;
  $(function(){
  
  $('#drpcategory').on('change',function()
  {
  
  $.ajax({
  method: 'post',
  data: $(this).serialize(),
  success: function(result) {
  console.log(result);
  }
  });
  
  });    
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>This seems to be currently working as I'm getting outputs like below in <strong>Chrome</strong> Browser > <strong>Inspect</strong> > <strong>Network</strong> tab every time I make a selection in <code>drpcategory</code>. Here is the screenshot;</p>
  
  <p><a href="https://i.stack.imgur.com/7VMOw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7VMOw.jpg" alt="Google Chrome Developer Tools Capture"></a></p>
  
  <p>The question is how can I capture this AJAX <code>post</code> data using PHP within the same page and <code>echo</code> it within the same page? So far I have tried;</p>
  
  <pre><code>&lt;?php 
    if(isset($_POST['drpcategory']))
    {
      echo 'POST Received';
    }
  ?&gt;
  </code></pre>
  
  <p>I'm looking for a solution using only PHP, JQuery and AJAX combined.</p>
  
  <p><strong>This question was later updated and answered here</strong>:
  <a href="https://stackoverflow.com/questions/54968749/ajax-post-php-post-in-same-page">AJAX POST &amp; PHP POST In Same Page</a></p>