I am trying to pass a StringBuilder message as an extra data back to ajax call but I am failing to manipulate it in client side. Below is the way I append message to StringBuilder and pass it back.
StringBuilder retMessage=new StringBuilder();
retMessage.Clear().AppendLine("Successfully added the user!");
//Clear will done only on Success otherwise will append the different errorMessage using AppendLine
return Json(new { result = valid, message = retMessage });
On the ajax Success I tried retrieving it as below but with no success.
success: function (data) {
if (data.result) {
ResetForm('#frmChangePwd');
console.log(data.message);
},
}
Below are images showing how it is passed from server side and how it is obtained in client side!!
Server Side return

Client Side retrieval

Can anyone tell me how to retrieve message in client side and display it in view?
.ToString()on theStringBuilder-return Json(new { result = valid, message = retMessage.ToString() });.ToString()your passing the instance of theStringBuilderso theJsonmethod serializes the instance from its public properties, but the actual text output is internal so its not sent - only the 3 public properties that you see in the browser