Illegal invocation 的解决方法
当使用ajax 想后端传送数据时 出现一下情况:
Uncaught TypeError: Illegal invocation
at e (jquery.min.js:4)
at Ab (jquery.min.js:4)
at Function.n.param (jquery.min.js:4)
at Function.ajax (jquery.min.js:4)
at Object.onEditableSave (item:213)
at e.trigger (bootstrap-table.min.js?v=20191219:6)
at HTMLAnchorElement.<anonymous> (VM993 bootstrap-table-editable.js:123)
at HTMLAnchorElement.dispatch (jquery.min.js:3)
at HTMLAnchorElement.r.handle (jquery.min.js:3)
at Object.trigger (jquery.min.js:3)
我的ajax代码为:
var formData = new FormData();
formData.append("state",row.state);
formData.append("itemId",row.itemId);
$.ajax({
type:'post',
data: formData,
url:"/create/item/edit",
success : function(data) {
if(data.msg!="操作成功"){
$.modal.msgError("修改错误,请重新更改");
}
}
});
因为使用formData ,此时需要增加两个参数:
contentType : false,
processData : false,
完成后代代码为:
$.ajax({
type:'post',
data: formData,
contentType : false,
processData : false,
url:"/create/item/edit",
success : function(data) {
if(data.msg!="操作成功"){
$.modal.msgError("修改错误,请重新更改");
}
}
});