title: Undefined Index Name when trying to pass values from Jquery to PHP
body: <p>So, I'm working on figuring out how to post data from Jquery to PHP, And as much as I follow the examples I've found on the threads here, I keep getting an "Undefined Index Name" error.</p>
  
  <p>My code thus far for the JQuery side is</p>
  
  <pre><code>&lt;script src="jquery-1.11.1.min.js"&gt;&lt;/script&gt;
  &lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
       $("#div2").text('Hey');
      $("#div1").load('testFile.txt');
      setInterval(function() {
      $.ajax({ url: 'script.php' });
      $("#div1").load('testFile.txt');}
      ,100);
  
  
  
    });
    function sub(){
  
       var msg = $("#name").val();
  
       $.post('chat.php',{'name':"1234"},function(){
  $("#div2").load('chat.php');
  });  
   };
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The html forms and buttons I'm using</p>
  
  <pre><code>&lt;div id="div1"&gt;&lt;/div&gt;
  &lt;div id="div2"&gt;Um&lt;/div&gt;
  
  &lt;form name="myForm" id="myForm" action="" method="POST"&gt;
  &lt;input type="text" name="name" id="name" size="30" value=""/&gt;
  &lt;/form&gt;
  &lt;button id="submission" onclick="javascript:sub();"&gt;Errrr&lt;/button&gt;
  </code></pre>
  
  <p>And the PHP side I'm going to </p>
  
  <pre><code>&lt;?php
  echo $_POST['name'];
   $myFile = "testFile.txt";
   $fh = fopen ($myFile, 'a+') or die("Cannot Open File");
   fwrite ($fh, $_POST['name']);
   fclose($fh);
  
  ?&gt;
  </code></pre>
  
  <p>I'm about at a loss from where to do. All files are within the same folder and filenames are correct as far as I can find.</p>