我使用此代码来获取检查日期,但它没有获取 int[] 值。哪里错了。
查看页面:
function displayCheckedPersons() {
var $checkedRecords = new Array();
var j;
j = 0;
var nodes = $("#PersonTree").jstree("get_checked",null,true);
$.each(nodes, function (i, element) {
if ($(element).attr("ifPerson") == "Y") {
$checkedRecords[j] = $(element).attr("id");
j = j + 1;
};
});
if ($checkedRecords.length < 1) {
alert('Please Select Persons first.');
return;
}
$('#result').load('<%= Url.Action("DisplayCheckedPersons", "Scheduling") %>',$checkedRecords);
}
</script>
操作代码:
public ActionResult DisplayCheckedPersons(int[] checkedRecords)
{
AttendMSDataContext db = new AttendMSDataContext();
checkedRecords = checkedRecords ?? new int[] { };
return PartialView("CheckedPersons", db.Persons.Where(o => checkedRecords.Contains(o.id)));
}
dai 编辑:我使用 $ajax 发布数组,如下所示:
$.ajax({
type: "POST",
url: "<%= Url.Action("DisplayCheckedPersons", "Scheduling") %>",
data: { checkedRecords: checkedPersons },
dataType: "html",
success: function (request) { $("#result").html(request); },
traditional: true
});