title: Contact form using PHP and jQuery form plugin
body: <p>I'm using the jQuery Form plugin to submit AJAX requests. It's a simple contact from using this PHP script: <a href="http://pastie.org/725652" rel="nofollow noreferrer">http://pastie.org/725652</a> - the only validation happens inside the PHP.</p>
  
  <p>Here's my Javascript code to trigger the whole thing: </p>
  
  <pre><code>$('#contactform').ajaxForm({
      target: '#error',
      beforeSubmit: function() {
          $('#error').append('&lt;p class="loading"&gt;Sending your message...&lt;/p&gt;');
      },
     success: function() {
         $('#error p.loading').fadeOut();
         $('#error').fadeIn('slow');
      }
  });
  </code></pre>
  
  <p>Unfortunately, it doesn't seem to work. The PHP works perfectly, sends the email and returns the success message, but the AJAX magic isn't working for some reason. Obviously what I want to achieve, is to display the message returned by the PHP script via AJAX in the <code>&lt;div id="error /&gt;</code></p>
  
  <p>I used the same script many times and never had any problems with it, now I can't figure out why it doesn't work. Here's the markup for the contact form.</p>
  
  <pre><code>&lt;form id="contactform" class="group" method="post" action="submitemail.php"&gt;
      &lt;fieldset&gt;
          &lt;div&gt;&lt;label for="first-name"&gt;First Name&lt;/label&gt;
          &lt;input type="text" name="first-name" value="Jeremy" /&gt;&lt;/div&gt;
  
          &lt;div class="alt"&gt;&lt;label for="last-name"&gt;Last Name&lt;/label&gt;
          &lt;input type="text" name="last-name" value="Anderson" /&gt;&lt;/div&gt;
  
          &lt;div&gt;&lt;label for="email"&gt;E-mail &lt;span&gt;(never published)&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" name="email" value="jeremyanderson@mywebsite.com" /&gt;&lt;/div&gt;
  
          &lt;div class="alt"&gt;&lt;label for="url"&gt;Website&lt;/label&gt;
          &lt;input type="text" name="url" value="http://www.mywebsite.com" /&gt;&lt;/div&gt;
  
          &lt;label for="question"&gt;Message&lt;/label&gt;
          &lt;textarea name="question" id="" cols="30" rows="10"&gt;Thinking of something to say...&lt;/textarea&gt;
  
          &lt;input type="submit" name="submit" id="submit" value="Send E-mail" /&gt;
          &lt;div id="error"&gt;&lt;/div&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here's the code of the jQuery plugin if it can be any help. <a href="http://pastie.org/726175" rel="nofollow noreferrer">http://pastie.org/726175</a></p>
  
  <p>If anyone could look at the whole thing and provide some tips why would it not work, I would be very grateful, thanks in advance!</p>