title: How to clear a form using Ajax/JS
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6653556/jquery-javascript-function-to-clear-all-the-fields-of-a-form">jQuery/Javascript function to clear all the fields of a form</a>  </p>
  </blockquote>
  
  
  
  <p>I need to clear the form after submit but none of the methods I've seen works for me. I'm using a script I bought but the author isn't answering my request. I have JS file with this:</p>
  
  <pre><code>$('#contact_form').submit(function () {
          $.ajax({
              type: 'POST',
              url: 'contact.php',
              data: {
                  name: $('#contact_form input#name').val(),
                  email: $("#contact_form input#email").val(),
                  text: $("#contact_form textarea").val()
              },
              success: function(data) {
                  if ( data == 'sent' ) {
                      $('#contact_form .status').html('Thanks');
                  } else if ( data == 'invalid' ) {
                      $('#contact_form .status').html('Invalid.');
                  } else {
                      $('#contact_form .status').html('Can't send message.');                 
                  }
              },
              error: function () {
                  $('#contact_form .status').html('Can't send message.');
              }
          });
          return false;
      });
  
  
  }
  </code></pre>