title: Submit form with ajax in wordpress
body: <p>I am trying to create jquery function which send my html form with ajax. I build standard html form with POST method and now I am trying to create jquery part and there is a problem. Here is my code:</p>
  
  <pre><code>$(document).ready(function() {
  $('form').submit(function() {
      var formData = $('form').serialize();
      var href = 'http://stravomat.michalfolprecht.com/wp-admin/admin-ajax.php';
      $.post(href, formData, function(resp) {
              console.log(resp);
              if ( resp.success ) {
                  console.log('success');
  
              } else {
                  console.log('alert');
              }
          });
  
      // stop the form from submitting the normal way and refreshing the page
      event.preventDefault();
  });
  </code></pre>
  
  <p>});</p>
  
  <p>I have php part on the same page where is the form and this is standard wordpress custom page template. Jquery code is in custom file and linked to wordpress header. I do not know if I should use ajax url or use url page. When I try to use this code console log give me number 0  that's all. Can you someone help me with this?</p>
  
  <p>Thanks for reply.</p>
  
  <p>Michal.</p>