title: Get variable $_GET with ajax
body: <p>I'm trying to build an ajax live search.</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;div class="input-group"&gt;
          &lt;span class="input-group-addon"&gt;Search&lt;/span&gt;
          &lt;input type="text" name="search_text" id="search_text" class="form-control" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="result"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  $(document).ready(function() {
      load_data();
      function load_data(query) {
          $.ajax({
              url:"new/new_fetch.php",
              method:"POST",
              data:{query:query},
              success:function(data) {
                  $('#result').html(data);
              }
          });
       }
       $('#search_text').keyup(function() {
           var search = $(this).val();
           if(search != '') {
               load_data(search);
           } else {
               load_data();
           }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>new/new_fetch.php</p>
  
  <pre><code>$connect = mysqli_connect("localhost", "root", "root", "dbname");
  if(isset($_POST["query"])) {
      $query = "SELECT * FROM subcategories WHERE category_parent = '".$_GET['category']."' ORDER BY subcategory";
  }
  </code></pre>
  
  <p>But I have an <code>Undefined index: category in new/new_fetch.php</code> error. </p>
  
  <p>My code works without WHERE operator.</p>
  
  <p>How can I get <code>$_GET['category']</code> using ajax POST method? thx</p>