我正在開發一個帶有razor語法的MVC3應用程序。我正在研究評論功能的部分類。無法通過部分視圖的JQuery中的ViewBag發送參數。
我的代碼是:
<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>
我想參數發送到從視圖控制器,使用ViewBag,在上面的jQuery,但它不工作。我怎樣才能做到這一點?
腳本中呈現了什麼值?你能告訴我們結果嗎? –