title: JQuery posting files and text through ajax
body: <p>I've got a Django webapp with a sort of newsfeed functionality. Newsfeeds have titles, bodies, and images associated with them. Users have the ability to edit and update their newsfeeds, including adding a new image.</p>
  
  <p>Currently I'm getting all the data for each feed item like so:</p>
  
  <pre><code>var newsfeeds = [];
  $('.feed').each( function (index, element) {
      var feed_dict = {'title': $(this).children('#title').val(),
                       'id': $(this).children('#feed_' + index + '_id').val(),
                       'should_delete': $(this).children('#should_delete').val(),
                       'subtitle': $(this).children('#subtitle').val(),
                       'body': $(this).children('#body').val()};
      newsfeeds.push(feed_dict);
  });
  </code></pre>
  
  <p>It's then sent off using <code>$.ajax()</code>. This is working great.</p>
  
  <p>Now I'm working on the image stuff. Each feed has an associated <code>&lt;input type="/&gt;</code> with a unique ID, so I should be able to get each file. The question then is how to send them off in such a way that I can get all the data in Django's <code>request.POST</code> and <code>request.FILES</code>. I've tried using a <code>FormData</code> object in JS like so:</p>
  
  <pre><code>var data = new FormData();
  $('.image_input').each(function(index, element) {
      data.append('file_' + index, element.files);
  });
  </code></pre>
  
  <p>But this gives me a <code>NS_ERROR_CANNOT_CONVERT_DATA</code> in Firebug.</p>
  
  <p>At this point, I'm pretty lost. Any pointers would be very helpful.</p>