title: Sending a blob over ajax post
body: <p>I am trying to send an audio blob over to my Rails action through an ajax POST. I seem to get over to the Rails action but the data I am sending appears to be empty and my audio file is not saved. I can do this with simple javascript, but I cannot seem to get this to work with ajax.</p>
  
  <p>Ajax not working:</p>
  
  <pre><code>function sendRecToPostAjax(blob){
  
      var data = new FormData();
      data.append("audio", blob, (callid + ".oga"));
      data.append('callid', callid);
  
      return $.ajax({
          url: '/controller/action',
          type: 'POST',
          cache: false,
          data: data,
          processData: false,
          contentType: false
      });
  }
  </code></pre>
  
  <p>JS working:</p>
  
  <pre><code>function sendRecToPost(blob) {
  
    var data = new FormData();
    data.append("audio", blob, (callid + ".oga"));
    data.append('callid', callid);
  
    var oReq = new XMLHttpRequest();
    oReq.open("POST", "/controller/action");
    oReq.send(data);
  
    oReq.onload = function(oEvent) {
        if (oReq.status == 200) {
            console.log("Uploaded");
        } else {
            console.log("Error " + oReq.status + " occurred uploading your file.");
        }
    };
  }
  </code></pre>