Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在html中显示json对象_Json - Fatal编程技术网

无法在html中显示json对象

无法在html中显示json对象,json,Json,我试图显示错误消息的通知,但我看到的是带有格式的实际json数据 notificationMsg({ text: data.responseText, type: 'error', hide: false }); 显示的结果是: {“Title”:“Error”,“Message”:“Error with Account login”,“Type”:3,“Data”:null,“Hide”:false,“IsClientMessage”:true,“TypeString”:“Error”} 我

我试图显示错误消息的通知,但我看到的是带有格式的实际json数据

notificationMsg({ text: data.responseText, type: 'error', hide: false });
显示的结果是:

{“Title”:“Error”,“Message”:“Error with Account login”,“Type”:3,“Data”:null,“Hide”:false,“IsClientMessage”:true,“TypeString”:“Error”}

我希望它看起来像这样:

错误
帐户登录错误

我试过:

notificationMsg({ text: JSON.parse(data.responseText), type: 'error', hide: false });
但结果是

[Object Object]

如何在没有格式化的情况下正确显示错误消息?

您需要解析JSON,请尝试以下代码

  objResposneText = JSON.parse(data.responseText);
  notificationMsg({ text: objResposneText.Title, type: 'error', hide: false });
  notificationMsg({ text: objResposneText.Message, type: 'error', hide: false });
或用于单个通知消息

  notificationMsg({ text: objResposneText.Title + " " + objResposneText.Message, type: 'error', hide: false });

尝试添加
var objResposneText=JSON.parse(data.responseText)
before
notificationMsg({text:objResposneText.Title,键入:'error',hide:false})是的,我意识到我错过了,所以我继续添加它-谢谢你的帮助!!