ajaxSubmit - jQuery FormData Plugin

Craig Blanchette on Google+ on March 26th 2013

Using iframes to submit form data can get messy. Using FormData objects, you can submit multipart form data over AJAX. The biggest issue here is that FormData will only work starting IE10+. It works on most other modern browsers. Here is a quick snippet of how you can use the plugin:

  1. <form id="myform" method="post" enctype="multipart/form-data">
  2. <input type="file" name="myfile">
  3. <input type="text" name="filename">
  4. <button type="submit">Upload</button>
  5. </form>
  1. $('#myform').submit(function(e){
  2.  
  3. $(this).ajaxSubmit(function(data, textStatus, xhr){
  4. // ...
  5. });
  6.  
  7. e.preventDefault();
  8. });
There is more in the README on my github. You can also download the plugin here as well.