0

这是模型中的属性:

[Required]
[Display(Name="Qualifications")]
public List<string> Qualifications { get; set; }  

这是JS代码

  var data = {
  UserName : $("#name").val(),
  Qualifications: $("input[name='Qualifications']").map(
  function()
  {
    return $(this).val();}).get()
  }
    if(condition)
  {
   alert(JSON.stringify(data));
  $.ajax({
  url :"ActionMethodName",
  type:"POST",
  datatype:"json",
  data:data,
  success:function() 
  {any code}
  })}  

动作方法

[HttpPost]  
public ActonResult Register(RegisterationModels mode)  
{
   LoginRegisterationManager manager = new LoginRegisterationManager();
    int ret =  manager.Register(model.UserName, model.Password, model.DatOfBirth, model.SSN, model.Qualifications);
            if (ret != 0)
            {
                return Json(new { success = true });
            }
            else 
            {
                return Json(new { success = false});
            }

}

我找不到道具,alerting [data] 显示 JSON 对象格式正确,并且操作方法中的模型参数映射除了列表之外的所有道具?

记录输出的 JSON 对象:{"UserName":"omAhmed","Password":"223311","DatOfBirth":"02-02-1998","SSN":"55446‌​677443388","Qualifications":[ "lkjhhu","'ljbv","lohvb"]}

4

0 回答 0