【发布时间】:2014-06-21 22:26:46
【问题描述】:
我使用 Asp.net MVC。我有一个页面。当我单击页面上的菜单链接时,我想将部分视图加载到该页面。我写了如下代码。
$("a.submit").click(function () {
var id = $(this).attr("id");
var UnitId = id.split("_")[1];
var categoryId = $("#hdnCategory").val();
$.blockUI({
css: { backgroundColor: 'transparent', color: '#fff', border: 'none' },
message: '<h1><img src="../Content/images/loading.gif" style="width:300px;height:300px" /></h1>'
});
$.ajax({
url: '@rootPath/KaliteDokumanYonetimi/GetDocumentsByUnit',
type: 'GET',
dataType: 'json',
contentType: 'application/json;charset=utf-8',
data: '{unitId:'+UnitId+'}',
success: function (result) {
// alert("success");
$.unblockUI();
},
error: function () {
$.unblockUI();
alert("sorun oluştu");
}
});
});
//this is also my controller action code piece.
public JsonResult GetDocumentsByUnit(string unitId)
{
return Json(true,JsonRequestBehavior.AllowGet);
}
我的代码和上面一样。我的问题是,我无法从 Action Method 中获取 unitI 值。它是空的。在 javascript 方面,我控制它正确的这个值。如何从 Action 方法中获取 unitId 值。 提前谢谢...
【问题讨论】:
-
这不是建议问题的重复...他在 ajax 调用之后没有做任何事情,并表示他的问题是
unitId在操作方法中是null。
标签: jquery asp.net-mvc json asp.net-mvc-4