大佬教程收集整理的这篇文章主要介绍了ajax contentType false 导致错误:XML 解析错误:格式不正确,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 AJAX 在 formData 中发布一个图像文件数组和一个对象。 我已将 ContentType 设置为 false,firefox 在控制台中显示此错误。
XML 解析错误:格式不正确
这是AJAX代码:
const addForm = document.querySELEctor('#addForm');
let fd = new FormData();
addForm.addEventListener('submit',(event) => {
event.preventDefault();
const newProduct = {
Cost: document.getElementByID('addPcost').value,Size: document.querySELEctorAll('[name="size"]:checked')[0].value,Material: document.querySELEctorAll('[name="material"]:checked')[0].value,color: document.getElementByID('addPcolor').value,category: document.querySELEctorAll('[name="category"]:checked')[0].value
}
imagefiles.forEach(image => {
fd.append("image",imagE);
});
fd.append("info",JsON.Stringify(newProduct));
$.AJAX({
type: "POST",url: "/addproduct",dataType: 'Json',ContentType: false,processData: false,data: fd,success: () => {
Notiflix.Notify.success("new product added successfully.");
removeAllpImage();
addForm.reset();
delete newProduct;
},error: (textStatus,err) => {
Notiflix.Notify.Failure('<h2>Internal Server Error</h2><br>' + 'text status ' + textStatus + ',err ' + err);
}
});
});
我应该为 AJAX 设置什么 ContentType 来防止这个错误?
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的ajax contentType false 导致错误:XML 解析错误:格式不正确全部内容,希望文章能够帮你解决ajax contentType false 导致错误:XML 解析错误:格式不正确所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。