title: Bad request 400. How should jQuery Ajax data serialize() or json look like?
body: <p>I'm trying to send a form via jquery ajax. I have this:</p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>$('#form-pm').on('submit',function(e) {
  
          e.preventDefault();
  
          var formData = $('#form-pm').serialize();
          var ajaxRequest =
          $.ajax({
              url: //my valid url,
              dataType: 'json',
              contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
              type: 'post',
              data: formData    
          });
  
          ajaxRequest.done(function(data) { console.log(data); });
          ajaxRequest.fail(function(jqXHR) { alert('You are fail. ' + jqXHR); });
  
      });
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  <em>JS looks like this now:</em></p>
  
  <pre><code>var formData = $('#form-pm').serialize();
  
          var ajaxRequest =
          $.ajax({
              url: admin_ajax.ajax_url,
              type: 'post',
              data: formData
  
          });
  
          ajaxRequest.done(function(data) { console.log(data); });
          ajaxRequest.fail(function(jqXHR) { alert('You are fail. ' + jqXHR); });
          e.preventDefault();
  </code></pre>
  
  <p>400 Bad Request is gone, but my function send_message is receiving blank parameters. According to error.log, it's <code>send_message('',NULL,NULL)</code></p>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>function send_message($projectid, $userid, $message) {
      //do stuff
  }
  
  &lt;form id="form-pm" method="post" enctype="multipart/form-data" action=""&gt;
      &lt;textarea name="message" rows=3 id="project-message"&gt;&lt;/textarea&gt;
  
      &lt;input type="submit" name="send" value="send message"&gt;
  
      &lt;input id="userid" type="hidden" name="userid" value="&lt;?php echo $userid; ?&gt;"&gt;
      &lt;input id="projectid" type="hidden" name="projectid" value="&lt;?php echo $projectid; ?&gt;"&gt;
      &lt;input id="userid" type="hidden" name="action" value="send_message"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>I keep getting POST 400 Bad Request. I know it's <code>data</code> that is causing trouble. How does post expect <code>data</code> to look like?</p>