Passing javascript variable to PHP
<p>I refer to this question:
<a href="http://stackoverflow.com/questions/5882442/javascript-value-to-php-with-jquery">Javascript value to PHP with Jquery</a></p>

<p>I tried with below code in file named a.php:</p>

<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
 var ms = 9000;
function test()
{
    $.ajax({ url: "a.php",
         data: {"test":ms},
         type: 'get',
         success: function(output) {
                      $('#testing').html(output);
                  }
    });
}
test();
&lt;/script&gt;
&lt;?php
$ms = $_GET["test"];
echo "I am getting below value:";
echo $ms;
?&gt;
</code></pre>

<p>Then I point browser to <a href="http://localhost/learn/a.php" rel="nofollow">http://localhost/learn/a.php</a> but got error message &amp; value of $ms is not shown as expected:</p>

<blockquote>
  <p>( ! ) Notice: Undefined index: test in
  C:\wamp\www\learn\a.php on line 17</p>
  
  <p>$ms = $_GET["test"]; &lt;-- The line 17
  in a.php</p>
</blockquote>

<p>I tried another simpler code (b.php) below:</p>

<pre><code>&lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
 var ms = 3000;
 $.get("http://localhost/learn/b.php", { "test": ms } );
&lt;/script&gt;
&lt;?php
$ms = $_GET["test"];
echo $ms;
?&gt;
</code></pre>

<p>Then I point browser to <a href="http://localhost/learn/b.php" rel="nofollow">http://localhost/learn/b.php</a> but got similar error message &amp; no value of $ms displayed:</p>

<blockquote>
  <p>( ! ) Notice: Undefined index: test in
  C:\wamp\www\learn\b.php on line 7
  Below is code of line 7
      $ms = $_GET["test"];</p>
</blockquote>

<p>Please advice. Thanks.</p>
