我正在尝试通过ajax上传文件但是当我尝试访问该文件时,我收到此错误:
NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object
在jquery min on line:
b = f.isFunction(b) ? b() : b, d[d.length] = encodeURIComponent(a) + "=" + encodeURIComponent(b)
这是我的jquery代码:
$('#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");
}
});
});
我的表格
<form accept-charset="UTF-8" action="/crash_report/ar_save" class="changedateformat" enctype="multipart/form-data" id="new_ar_bji_o_involved" method="post">
<input id="ar_bji_o_involved_mugshot" name="ar_bji_o_involved[mugshot]" type="file">
</form>
我正在使用ruby on rails carrier wave gem
上传文件。但是我在使用firebug调用控制器之前遇到错误。
我有这个代码可以正常工作:
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); // <-- provide the proper URL
xhr.send(A);
你们可以从这里提出建议吗?
提前致谢。