0

Here is the property in the model :

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

And here is the JS code

  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}
  })}  

The action method

[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});
            }

}

I can not find the prop, alerting [data] shows me that the JSON object is well formed, and the model parameter in the action methods maps all the props except for the list??

Logging the JSON object outputted: {"UserName":"omAhmed","Password":"223311","DatOfBirth":"02-02-1998","SSN":"55446‌​677443388","Qualifications":["lkjhhu","'ljbv","lohvb"]}

6
  • show the action method? Commented May 5, 2013 at 12:34
  • return $(this).val();}).get() this line has syntax errors. and why are you doing $.get() ? Commented May 5, 2013 at 17:10
  • i havent found any syntax errors, ill review the code then reply, thanks Commented May 5, 2013 at 17:53
  • Logging the JSON object outputted: {"UserName":"omAhmed","Password":"223311","DatOfBirth":"02-02-1998","SSN":"55446677443388","Qualifications":["lkjhhu","'ljbv","lohvb"]} Commented May 5, 2013 at 18:38
  • is not it right format for the JSON ? Commented May 5, 2013 at 18:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.