title: Building a multipart/form-data request in javascript/jquery
body: <p>I've been doing some searching and trying to figure out how to build a request to send through something like </p>
  
  <pre><code>   $.ajax({
              contentType: "multipart/form-data",
              type: "POST",
              data: data,
              url: url,
              success: function (data) { }
          });
  </code></pre>
  
  <p>Now the request itself should look something like this where it's a json job part, then json detail part, and associated file</p>
  
  <pre><code>Content-Type: multipart/form-data; boundary=4fed9b4a-7aae-430f-b907-cbefe7e22c55
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55
  Content-Type: application/vnd.collection+json
  Content-Disposition: form-data; name=job
  
  {json}
  
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55
  Content-Type: application/vnd.collection+json
  Content-Disposition: form-data; name=details
  
  {json}
  
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55
  Content-Type: application/pdf
  Content-Disposition: form-data; filename=moo.pdf
  
  xxxxxxxxxxxxxxxxx
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55
  Content-Type: application/vnd.collection+json
  Content-Disposition: form-data; name=details
  
  {json}
  
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55
  Content-Type: application/pdf
  Content-Disposition: form-data; filename=doh.pdf
  
  xxxxxxxxxxxxxxxxxxxxxxxxxxx
  --4fed9b4a-7aae-430f-b907-cbefe7e22c55--
  </code></pre>
  
  <p>So using Javscript and assuming i have the file data and the json data how would i construct a request that i could send in the above ajax call? Thanks</p>