Currently, I am in the process of building an MVC3 application with razor syntax. My focus right now is on developing the partial class that will be responsible for handling comments.
This is a snippet of my code:
<script src="../../Scripts/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#AddCommentButton').click(function () {
$.ajax({
type: 'post',
url: '/Comment/SaveComments',
dataType: 'json',
data:
{
'comments': $('#Comment').val(), @ViewBag.EType, @ViewBag.EId
},
success: function (data) {
$("p.p12").append
$('.ShowComments').text('Hide Comments');
}
});
});
});
</script>
I am encountering an issue where I am attempting to pass parameters from the View to the controller using ViewBag within the jQuery code above, but it appears to not be functioning as expected. Any suggestions on how I could resolve this?