title: getting undefined index error in php
body: <p>I just want receive the array and print it which is sent by <code>jquery.post()</code></p>
  
  <p>my HTML-JS</p>
  
  <pre><code>&lt;input type="submit"  id="myButton" /&gt;
  
  &lt;script type="text/javascript"&gt;
  
      var arr = new Array();
      arr[0] = "Ding";
      arr[1] = "Dong";
      arr[2] = "Bong";
  
      var json_string= JSON.stringify(arr); // convert it into a json string. 
  
      //and sending the data to server. temp.php.
      $("#myButton").click(function(){
      $.post('temp.php' , {json : json_string },function(data){
  
                         location.href = "temp.php";
           }); 
  
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I have checked by <code>alert()</code> that data sending is successful. After button click page is also redirecting to <code>temp.php</code></p>
  
  <p>My php page <code>temp.php</code></p>
  
  <pre><code>&lt;?php
      $json_string = $_POST['json']; //geting the post request. //this is line 3
      $array_items = json_decode($json_string); //converting json string to a php array.
      echo $array_items[0]; //just to print 1st element of array
   ?&gt;
  </code></pre>
  
  <p>It should print <code>Ding</code>. But I am getting error</p>
  
  <pre><code>Undefined index: json in C:\wamp\www\phpJSarray\temp.php on line 3
  </code></pre>
  
  <p>What is my mistake in temp.php page ? Please help me out.</p>