title: Auto submit form to update ajax on html page
body: <p>I'm trying to use setInterval to refresh page data every 5 seconds. I have a simple html form with one textbox with the ID of 'name'. I have a submit button as well which works fine(code also below) but I can't get the page to POST on it's own. All help appreciated.</p>
  
  <pre><code>&lt;script type="text/javascript" src="/media/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function () {
      window.setInterval(function() {
          AutoPost();
      }, 5000);
  });
  
  function AutoPost() {
      $.ajax({
          // post the form values via AJAX…
          var postdata = {name: $("#name").val()} ;
          $.post('/submit', postdata, function(data) {
              // and set the title with the result
              $("#title").html(data['title']) ;
             });
          return false ;
          });
      });
  }
  
  
  $(function() {
  // When the testform is submitted…
  $("#testform").submit(function() {
      // post the form values via AJAX…
      var postdata = {name: $("#name").val()} ;
      $.post('/submit', postdata, function(data) {
          // and set the title with the result
          $("#title").html(data['title']) ;
         });
      return false ;
      });
  });
  </code></pre>
  
  <p></p>