title: Pass javascript variable to php with ajax and the result doesn't show anything
body: <p>This is my code and i want to pass javascript variable with ajax to php when i click submit button then the result doesn't show var_data variable from javascript What code is wrong?
  This is edit order one before everybody help me</p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
          $(document).ready(function() {
              $('#sub').click(function() {
                  var var_data = "Hello World";
                  $.ajax({
                      url: 'http://localhost/ajax/PassVariable.php',
                      type: 'GET',
                       data: { var_PHP_data: var_data },
                       success: function(data) {
                           // do something;
  
                       }
                   });
               });
           });
   &lt;/script&gt;
  
   &lt;/head&gt;
   &lt;body&gt;
  
   &lt;input type="submit" value="Submit" id="sub"/&gt;
  
   &lt;?php 
     $test = $_GET['var_PHP_data'];
       echo $test;
   ?&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>and this is source code now </p>
  
  <pre><code> &lt;?php
       if (isset($_GET['var_PHP_data'])) {
         echo $_GET['var_PHP_data'];
       } else {
       ?&gt;
       &lt;!DOCTYPE html&gt;
       &lt;html&gt;
         &lt;head&gt;
              &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"&gt;&lt;/script&gt; 
              &lt;script src="http://malsup.github.com/jquery.form.js"&gt;&lt;/script&gt; 
           &lt;script&gt;
               $(document).ready(function() {
                   $('#sub').click(function() {
                       var var_data = "Hello World";
                       $.ajax({
                           url: 'http://localhost/test.php',
                           type: 'GET',
                            data: { var_PHP_data: var_data },
                            success: function(data) {
                                // do something;
                               $('#result').html(data)
                            }
                        });
                    });
                });
           &lt;/script&gt;
         &lt;/head&gt;
         &lt;body&gt;
           &lt;input type="submit" value="Submit" id="sub"/&gt;
           &lt;div id="result"&gt;
         &lt;/body&gt;
       &lt;/html&gt;
      &lt;?php } ?&gt;
  </code></pre>
  
  <p>this statement if(isset($_GET['var_PHP_data'])) output false and then show Hello World What should i do to do for isset($_GET['var_PHP_data']) is true?</p>