我在每个图像前面带有复选框的图像视图列表中。复选框填充有图像 ID,因此我可以识别检查了哪个图像进行操作。
单击按钮时,我正在识别检查了哪些图像并将每个图像 id 存储到整数数组中。我想将这些数组发送到 mvc3 控制器,但我遇到了问题,我在发送的参数(萤火虫)中出现错误。例如,如果检查了两个图像,我得到以下信息:
undefined undefined
undefined undefined
这是代码
var imgList = [];
$('#deleteImgBtn').click(function () {
$('.imgCheckbox:checked').each(function () {
var id = $(this).attr('id');
imgList.push(id);
});
jQuery.ajaxSettings.traditional = true;
$.ajax({
url: '/property/deleteimages',
type: 'POST',
data: imgList ,
success: function(result){
alert("ok");
}
});
...
public ActionResult DeleteImages(int[] data)
{
return PartialView(data);
}