0

i am trying to display a notification of an error message but what i am seeing is the actual json data with formatting.

notificationMsg({ text: data.responseText, type: 'error', hide: false });

result displayed is:

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

i would like for it to appear like such:

Error
Error with Account login

i tried:

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

but the outcome was

[Object Object]

How can i properly display the error message without the formatting?

1 Answer 1

1

you need to parse JSON try following code

  objResposneText = JSON.parse(data.responseText);
  notificationMsg({ text: objResposneText.Title, type: 'error', hide: false });
  notificationMsg({ text: objResposneText.Message, type: 'error', hide: false });

or for single notification message

  notificationMsg({ text: objResposneText.Title + " " + objResposneText.Message, type: 'error', hide: false });
Sign up to request clarification or add additional context in comments.

2 Comments

try adding var objResposneText = JSON.parse(data.responseText); before notificationMsg({ text: objResposneText.Title, type: 'error', hide: false });
yes i realized that i missed that so i went ahead and added it - thanks for your help!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.