i am having a problem while retrieving the data coming from Json...
i am passing some values through $.ajax and i want to process that values in the controller..
please help, how can i retrieve the values in controller...
Jquery Code
var userID = @Model.User.UserID;
var postID = @Model.Post.PostID;
var commentBody = $('#textareaForComment').val();
$('#btnSubmit').click(function (e)
{
e.preventDefault();
var postdata =
{
CommentBody: commentBody,
PostID: postID,
UserID: userID
};
$.ajax({
url: '@Url.Action("SubmittedComment","Post")',
data: postdata,
success: function(data) {
$('#showComments').html(data);
}
});
});
now i am calling the SubmittedComment Action in the Post controller and i want to have the PostID,USerID and the CommentBody in that action and want to store it in a diff variable..
please help. thx
controller code
public JsonResult SubmittedComment(string CommentBody,UserID,PostID)
{
var result = CommentBody // i am not able to get the value here ....
}