Jquery
$('#PostComment').click(function () {
var commentTitle = $('#commentTitle').val();
var commentClob = $('#commentClob').val();
var id = $('#topicId').val();
var buttoname = $('#PostComment').val();
var obj;
$.ajax({
type: "post",
url: "../../Handler/Topic.ashx",
data: "commentclob=" + commentClob + "&commenttitle=" +
commentTitle + "&topicId=" + id + "&Button=" + buttoname,
success: function (msg) {
try {
alert(msg);
obj = jQuery.parseJSON(msg);
alert("Correct" + obj.CommentClob);
}
catch (e) {
alert("Incorrect" + e.Description + e.ErrorNumber);
}
}
});
return false;
});
});
Topic.ashx -ProcessRequest method
CommentModel cm = daoobject.populateCommentModel(listcommentsbytopic);
var json= cm.CreateCommentJson();
context.Response.Write(json);
Function definition
public string CreateCommentJson()
{
// serialize the names to JSON
var jss = new JavaScriptSerializer();
var json = jss.Serialize(this);
return json;
}
I am getting output 2 alert boxes
first is
{ "UserId": "1", "ToipicId": "44f94c32-c415-4751-812a-03b775775698", "CommentId": "0f1014a0-08d9-48f7-9a0c-d9d6b3d841b2", "CommentClob": "ilikeit", "CommentTitle": "nice", "DescriptionClob": null, "DateCreated": "/Date(1333233498780)/", "Datemodified": "/Date(-62135596800000)/" }
and second is
Incorrect undefined undefined
Can anyone help.
of a Firebug breakpoint.