【问题标题】:print json value which have php array value打印具有 php 数组值的 json 值
【发布时间】:2019-09-26 23:39:45
【问题描述】:
{"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 文件值

【问题讨论】:

标签: javascript php arrays codeigniter


【解决方案1】:

您必须捕获来自 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);

【讨论】:

  • 如果它回答了您的问题,请将其标记为答案。因此人们可以快速找到答案
猜你喜欢
  • 2015-09-28
  • 1970-01-01
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-04
相关资源
最近更新 更多