说明:开发环境 vs2012 asp.net mvc4 c#
1、HTML前端代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArrayTest.aspx.cs" Inherits="MvcAppTest.ArrayTest" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="ewJS/jquery.js"></script>
<script type="text/javascript">
var ids = [];
$(function () {
for (var i = 0; i < 20;i++)
{
var item = i + 1;
ids.push(item);
}
$.ajax({
url: 'Home/RemoveUser',
data: {
ids: ids.join(',')
},
type: "post",
dataType: 'json',
success: function (d) {
}
});
});
</script>
</head>
<body>
</body>
</html>
2、后台代码
[HttpPost]
public ActionResult RemoveUser()
{
var ids = Request["ids"].ToString();
var result = new ResultViewModel();
try
{
if (!String.IsNullOrEmpty(ids))
{
string[] pids = ids.Split(',');
}
result.success = true;
result.msg = "删除成功!";
}
catch
{
result.success = false;
result.msg = "删除失败!";
}
return Json(result);
}