title: AJAX Call - Does not recognize WP_Query
body: <p>i have Ajax call for getting response , in response file i have used wordpress loop And Get This Error :
  Fatal error: Class 'wp_query' not found ....</p>
  
  <p>i want to show Some Special Page Content in some div in Index.php and Return Result with Ajax to index.php</p>
  
  <p>Here :</p>
  
  <pre><code>   &lt;script&gt;
  myfunc = function()
  {           
      $("#target").slideUp(300);
      $("#target").slideDown(300,"swing",function()
          {                           
              splittedURL=window.location.href.split("#");
              $.post('&lt;?php bloginfo('template_directory'); ?&gt;/page.php','state='+splittedURL[1],function(data,status)
              {
                  $("#target").html(data);
              })      
          }
      );                          
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and Here Page :</p>
  
  <pre><code>&lt;?php
  $state=$_POST["state"];
  switch ($state) {
      case "2755":
          echo "&lt;b&gt;Ok 1&lt;b/&gt;";
          break;
      case "2756":
          echo "&lt;b&gt;Ok 2/b&gt;";
          break;    
      default:
    ?&gt;
    &lt;!-- Page Load --&gt;
   &lt;div id="panel-box" class="panel panel-default"&gt;
    &lt;div class="col-md-12 panel-heading"&gt;
    &lt;?php
      $my_query = new WP_Query('page_id=$state');
      while ($my_query-&gt;have_posts()):
      $my_query-&gt;the_post();
      $do_not_duplicate = $post-&gt;ID;?&gt;
      &lt;h3 class="col-md-11 panel-title p-m"&gt;&lt;?php the_title();?&gt;&lt;/h3&gt;
      &lt;div class="col-md-1 close p-m" onClick="$('#panel-box').slideUp(500)"&gt;X&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="panel-body"&gt;
  &lt;?php the_content(); ?&gt;
    &lt;/div&gt;
  
  &lt;?php endwhile; ?&gt;
  &lt;?php wp_reset_query(); ?&gt;
  
  &lt;!-- End Page Load --&gt;
   &lt;/div&gt;
  
    &lt;?php
  }
  ?&gt;
  </code></pre>