title: How do I automatically submit this form without refreshing the page?
body: <p>This is all in a php file</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;JQuery Form Example&lt;/title&gt; 
      &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"&gt;&lt;/script&gt;&lt;!--need at least one instance of jquery--&gt;
      &lt;script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"&gt;&lt;/script&gt;&lt;!--ajax to use with jquery--&gt;
      &lt;script type="text/javascript"&gt;
      $(document).ready(function(){//when the document has loaded
          $("#myform").validate({//Q: what is validate?, myform gets validated
              debug: false,
              rules: {
                  name: "required",//name and email are the only things passed
                  email: {
                      required: true,
                      email: true//I guess this defines the input as an email
                  }
              },
              messages: {//at what point is this message displayed?
                  name: "Please let us know who you are.",
                  email: "A valid email will help us get in touch with you.",
              },
              submitHandler: function(form) {//submit the form
                  // do other stuff for a valid form
                  $.post('process.php', $("#myform").serialize(), function(data) {//Q:what is serialization? myform gets serialized and assigned an action
                      $('#results').html(data);//what is this?
                  });
              }
          });
      });
  
      window.onload=function( )
      {
      }
  
  
      &lt;/script&gt;
      &lt;style&gt;
      label.error { width: 250px; display: inline; color: red;}
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form name="myform" id="myform" action="" method="POST"&gt;  
  &lt;!-- The Name form field --&gt;
      &lt;label for="name" id="name_label"&gt;Name&lt;/label&gt;  
      &lt;input type="text" name="name" id="name" size="30" value="Charlie"/&gt;  
      &lt;br&gt;
  &lt;!-- The Email form field --&gt;
      &lt;label for="email" id="email_label"&gt;Email&lt;/label&gt;  
      &lt;input type="text" name="email" id="email" size="30" value="obesemuleaccount@yahoo.com"/&gt; 
      &lt;br&gt;
  &lt;!-- The Submit button --&gt;
      &lt;input type="submit" name="submit" value="Submit"&gt; 
  &lt;/form&gt;
  &lt;!-- We will output the results from process.php here --&gt;
  &lt;div id="results"&gt;&lt;div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;!--ok, so I want to first try some stuff out to get a feel for how the form works--&gt;
  &lt;!--upload the form to the site somewhere--&gt;
  &lt;!--access and play around with it--&gt;
  &lt;!--then figure out how to submit to multiple php forms--&gt;
  </code></pre>
  
  <p>So I'm using Jquery and Ajax, and I need to submit the form automatically.</p>
  
  <p>I've tried using things like document.myform.submit, but that doesn't seem to work. It works when I am not using ajax, but that causes the page to refresh to the target of the php file.</p>
  
  <p>I think I'm just missing some syntax. I did a search and found a few threads like this one:
  <a href="https://stackoverflow.com/questions/3846203/ajax-auto-form-submit">Ajax auto form submit</a></p>
  
  <p>But I'm more of a hobbyist designer, so I don't really understand what they are saying. I wouldn't put the task of fixing my code on others, but I'm pretty sure the change is minor, and I've been up a while trying to figure this out. Many thanks to anyone that helps! Please be very detailed in your directions, it'd be best in fact if you could provide the fix directly in the code itself.</p>
  
  <p>edit: please don't laugh too hard at my comments, I understand the code (after much googling) much better now, that was a revision from a few hours ago.</p>
  
  <p>double edit: here's a sample php script called process.php, you will need to edit it to see if the autosubmit works though. As mentioned above, you can do this with a MySQL database.</p>
  
  <pre><code>print "Form submitted successfully: &lt;br&gt;Your name is &lt;b&gt;".$_POST['name']."&lt;/b&gt; and your email is &lt;b&gt;".$_POST['email']."&lt;/b&gt;&lt;br&gt;";
  </code></pre>