title: Submit form without refreshing page ajax,php,javascript?
body: <p>I want to submit a form without refreshing the page, from what I have read it should work with ajax, what am i doing wrong?</p>
  
  <p>it all works with the php and stuff when I do this:</p>
  
  <pre><code>document.getElementById("msg_form").submit();
  </code></pre>
  
  <p>But I want it to submit without refreshing the page.</p>
  
  <p>Part of Html:</p>
  
  <pre><code>&lt;form name="msg_form_name" id="msg_form" class="email" action="mailer.php"&gt;
  &lt;p&gt;Your E-mail:&lt;/p&gt;
  &lt;input id="email_form" name="email" type="text" /&gt;
  &lt;p&gt;Amount:&lt;/p&gt;
  &lt;input id="amount_form" name="amount" class="amount_num" type="text" maxlength="5" /&gt;
  &lt;div id="msg_txt_lenght"&gt;characters left: 38&lt;/div&gt;
  &lt;p&gt;Message:&lt;/p&gt;
  &lt;input id="message_form" name="message" class="message_form_lim" type="text" &gt;
  &lt;input type="hidden" id="storeUrl_id" name="storeUrl_form" value="Nan"&gt;&lt;/form&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Part of javascript:</p>
  
  <pre><code>$('#msg_form').submit(function (e) {
      e.preventDefault();
  
  $.ajax({             
  type: 'post',
  url: 'mailer.php',
  data: $('form').serialize(),
  success: function () {
   alert('form was submitted');
  }
      });
  
      return false;
  });
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: might have fixed it had it on submit but didn't send a submit</p>