title: Sending e-mail form using PHP and AJAX
body: <p>I have contact form on my site. It sends message to email. I try to do it without page reload using AJAX, but it seems that AJAX doesn't work: messages are sent but the page still redirecting to <code>call-form.php</code>. What is incorrect in my code? (jQuery is included)</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form name="freeCall" action="&lt;?php bloginfo(template_url); ?&gt;/mail/call-form.php" method="post" class="popover-form" id="free-call-form"&gt;  
      &lt;label for="name1"&gt;Name&lt;/label&gt;&lt;span class="pull-right close"&gt;&amp;times;&lt;/span&gt;&lt;input placeholder="Name" name="call-name" type="text" id="name1" &gt;  
      &lt;label for="phone"&gt;Phonenumber&lt;/label&gt;&lt;input name="phone" type="text" value="" placeholder="+375" id="phone" &gt;    
      &lt;input type="submit" value="Call me back" &gt;       
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>PHP - call-form.php</strong></p>
  
  <pre><code>&lt;?
  if((isset($_POST['call-name']))&amp;&amp;(isset($_POST['phone'])&amp;&amp;$_POST['phone']!="")){ 
          $to = 'test@gmail.com';
          $subject = 'Callback';
          $message = '
                  &lt;html&gt;
                      &lt;head&gt;
                          &lt;title&gt;Call me back&lt;/title&gt;
                      &lt;/head&gt;
                      &lt;body&gt;
                          &lt;p&gt;&lt;b&gt;Name:&lt;/b&gt; '.$_POST['call-name'].'&lt;/p&gt;
                          &lt;p&gt;&lt;b&gt;Phonenum:&lt;/b&gt; '.$_POST['phone'].'&lt;/p&gt;                        
                      &lt;/body&gt;
                  &lt;/html&gt;'; 
          $headers  = "Content-type: text/html; charset=utf-8 \r\n"; 
          $headers .= "From: Site &lt;info@mail.com&gt;\r\n"; 
          mail($to, $subject, $message, $headers); 
  }
  ?&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$(function () {    
        $("#free-call-form").submit(function () { 
          var form_data = $(this).serialize(); 
          $.ajax({
            type: "POST", 
            url: "call-form.php", 
            data: form_data,
            success: function () {
              alert("It's OK!");
            }
          });
        }); 
  });
  </code></pre>