title: issue with file upload via ajax
body: <p>I'm trying to upload a file through ajax but when I'm trying to access that file I'm getting this error: </p>
  
  <pre><code>NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object
  </code></pre>
  
  <p>In jquery min on line :</p>
  
  <pre><code> b = f.isFunction(b) ? b() : b, d[d.length] = encodeURIComponent(a) + "=" + encodeURIComponent(b)
  </code></pre>
  
  <p>Here is my jquery code:</p>
  
  <pre><code>$('#new_ar_bji_o_involved').submit( function(e){
  
      e.preventDefault();
      selectedid = $(this).attr('id');
      var report ={};
      report.authenticity_token = $(this).find('input[name=authenticity_token]').val();
      report.utf8 = $(this).find('input[name=utf8]').val()
      //$(this).serialize();
      report.other_involved = {};
      report.other_involved.ar_bail_juvinfo_id = $(this).find('#ar_bj_info_id').val();
      var d = document.getElementById('ar_bji_o_involved_mugshot');
      var B = d.files[0];
      report.other_involved.mugshot = B;
  
      $.ajax({
          type: "POST",
          url : "url?format=json",
          cache: false,
          data: report,
          contentType: "application/json",
          dataType: "json",
          success:function(data){
              //alert(data);
          },
          complete: function (data) {
               $("#dialog-message").dialog("open");
          }
      });     
  }); 
  </code></pre>
  
  <p>My form </p>
  
  <pre><code>&lt;form accept-charset="UTF-8" action="/crash_report/ar_save" class="changedateformat" enctype="multipart/form-data" id="new_ar_bji_o_involved" method="post"&gt;
  
  &lt;input id="ar_bji_o_involved_mugshot" name="ar_bji_o_involved[mugshot]" type="file"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I'm using <code>ruby on rails carrier wave gem</code> to upload the file. But I'm getting error  before the controller is called in firebug.</p>
  
  <p>I have this code which works fine:</p>
  
  <pre><code>var d = document.getElementById('imgid');
  A = new FormData();
  var B = d.files[0];
  
  A.append("contentType", "application/json");
                  A.append("key", "b7ea18a4ecbda8e92203fa4968d10660");
  A.append("employeeEvent[external_doc]", B);
  A.append("employeeEvent[description]", $('#descriptionid').val());
  A.append("employeeEvent[user_id]", $('#user_id').val());
  
  var xhr = new XMLHttpRequest();
   xhr.open("POST", "/employee_management/add_event?format=json", true);   // &lt;-- provide the proper URL
  
  xhr.send(A);
  </code></pre>
  
  <p>May be you guys can suggest something from here?</p>
  
  <p>Thanks in advance.</p>