{"success":"","error":"<span style='color: red;' id='inin'><p>The image you are attempting to upload doesn't fit into the allowed dimensions.<\/p><p>The image you are attempting to upload doesn't fit into the allowed dimensions.<\/p><\/span>",**"file":["asdf.PNG,","asdfgvb.PNG,"]**}
如何在JavaScript警报中打印JSON文件值
答案 0 :(得分:0)
您必须捕获xhr,JSON.Parse的响应,然后才能将其用作对象。就像警报中的object.error之类的东西。
因此,在最简单的解决方案中:
var obj = JSON.parse('{"success":"","error":"<span style='color: red;' id='inin'><p>The image you are attempting to upload doesn't fit into the allowed dimensions.<\/p><p>The image you are attempting to upload doesn't fit into the allowed dimensions.<\/p><\/span>","file":["asdf.PNG,","asdfgvb.PNG,"]}');
var d1 = document.getElementById('div');
d1.insertAdjacentHTML('beforeend', obj.error);