title: Ajax request php file result without refresh
body: <p>I have a html file with a search form:</p>
  
  <pre><code>&lt;form id="twit" method="post"&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;input type="text" name="venue" class="search-query form-control" placeholder="Venue Name" /&gt;
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;input type="text" name ="location" class="search-query form-control" placeholder="Venue City" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;span class="input-group-btn"&gt;
                  &lt;button type="submit" class="btn btn-danger" type="button"&gt;
                      &lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt;
                  &lt;/button&gt;
          &lt;/span&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>With this search form a try to submit two query parameters to the twitter search api.</p>
  
  <p>My php file is like this:</p>
  
  <pre><code>$url = "https://api.twitter.com/1.1/search/tweets.json";
  
  $requestMethod = "GET";
  
  //if ($_SERVER["REQUEST_METHOD"] == "GET") {
  //if(isset($_POST['venue']) &amp;&amp; !empty($_POST['location'])){
      $venue = $_GET['venue'];
      $location = $_GET['location'];
  
      $getfield = "?q=$venue+$location&amp;lang=en";
      $twitter = new TwitterAPIExchange($settings);
      $string = json_decode($twitter-&gt;setGetfield($getfield)
      -&gt;buildOauth($url, $requestMethod)
      -&gt;performRequest(),$assoc = TRUE);
      //if($string["errors"][0]["message"] != "") {echo "&lt;h3&gt;Sorry, there was a problem.&lt;/h3&gt;&lt;p&gt;Twitter returned the following error message:&lt;/p&gt;&lt;p&gt;&lt;em&gt;".$string[errors][0]["message"]."&lt;/em&gt;&lt;/p&gt;";exit();}
          foreach($string['statuses'] as $items)
          {
              //echo "Tweet: ". $items['text']."&lt;br /&gt;";
              // Create map with request parameters
              $params = array ('txt' =&gt; $items['text']);
  
              // Build Http query using params
              $query = http_build_query ($params);
  
              // Create Http context details
              $contextData = array ( 
                              'method' =&gt; 'POST',
                              'header' =&gt; "Connection: close\r\n".
                                          "Content-Type: application/x-www-form-urlencoded\r\n".
                                          "Content-Length: ".strlen($query)."\r\n",
                              'content'=&gt; $query );
  
              // Create context resource for our request
              $context = stream_context_create (array ( 'http' =&gt; $contextData ));
  
              // Read page rendered as result of your POST request
              $result =  file_get_contents (
                                'http://sentiment.vivekn.com/api/text/',  // page url
                                false,
                                $context);
  
              // Server response is now stored in $result variable so you can process 
              print_r($result."&lt;br /&gt;");
          }   
  //} //else {
      //echo "&lt;h3 id='submit-error'&gt;Sorry, there was a problem.&lt;/h3&gt;&lt;p&gt;Make sure you filled in all fields!&lt;/p&gt;&lt;p&gt;&lt;em&gt;";
  //}
  //}
  </code></pre>
  
  <p>When I go to the url like this <a href="http://twitter.somewebsite.com/twitter.php?venue=test&amp;location=washington" rel="nofollow">http://twitter.somewebsite.com/twitter.php?venue=test&amp;location=washington</a> I get the following from the sentiment engine (it takes a while any idea how I can speed it up? Api has this but dont know how I can incorporate that.A batch API has been added as the bottleneck for most of you will be in the network latency. To use it send a POST request with a JSON array of the texts you want to classify to <a href="http://sentiment.vivekn.com/api/batch/" rel="nofollow">http://sentiment.vivekn.com/api/batch/</a>. You will receive another JSON array of responses (similar to the one above) corresponding to the same order as in the request. The maximum content size can be 1 MB per request</p>
  
  <p>With a onclick function I try this but nothing happens:</p>
  
  <pre><code>$.getJSON( "twitter.php", { venue: "ikea", location: "amsterdam" } )
      .done(function() {
      alert( "success" );
    })
    .fail(function (xhr, ajaxOptions, thrownError) {
      alert(xhr.status);
      alert(thrownError);
    })
    .always(function() {
      alert( "complete" );
    });
  </code></pre>
  
  <p>I have little experience with PHp and almost no experience with ajax so thanks in advance.
  So my questions are:</p>
  
  <ul>
  <li>How can i retrieve the twitter.php result back into my html file?</li>
  <li>Can I speed up the sentiment analysis with the batch if so how?</li>
  </ul>