前台js代码
var result = [];
result.pust({
Answer: "A",
GID: '1'
});
result.pust({
Answer: "C",
GID: '2'
});
$.post(url,
{'stuList':JSON.stringify(result),//数组
'ID': ID,
'startTime': startTime,
'endTime':endTime},
function(data,status){
//对返回的数据data进行处理
}
});
后台controller接受
[HttpPost]
public ActionResult HandExam(string stuList,int ID,string startTime,string endTime)
{
string str = string.Empty;
//对数据进行解析 userAnswers是一个类
List<UserAnswers> list = JsonConvert.DeserializeObject<List<UserAnswers>>(stuList);
msg="ok";
return Content(msg);
}
userAnswers类
public class UserAnswers
{
public string Answer { get; set; }
public string GID { get; set; }
}