Skip to main content
added 354 characters in body
Source Link
Pranay Rana
  • 177.3k
  • 37
  • 244
  • 267

Edit try this , create array and pass that to your controller

 var stringArray = new Array(); stringArray[0] = "item1"; stringArray[1] = "item2"; stringArray[2] = "item3"; var postData = { listkey: stringArray }; 

than you data will be , in you ajax call

 data: postData $.ajax({ type: "POST", url: '@Url.Action("Search", "Result")', data: postData, success: function(data){ alert(data.Result); }, dataType: "json", traditional: true }); 

you can do like this ,

you can do like this ,

Edit try this , create array and pass that to your controller

 var stringArray = new Array(); stringArray[0] = "item1"; stringArray[1] = "item2"; stringArray[2] = "item3"; var postData = { listkey: stringArray }; 

than you data will be , in you ajax call

 data: postData $.ajax({ type: "POST", url: '@Url.Action("Search", "Result")', data: postData, success: function(data){ alert(data.Result); }, dataType: "json", traditional: true }); 

you can do like this ,

Source Link
Pranay Rana
  • 177.3k
  • 37
  • 244
  • 267

you can do like this ,

  1. convert you list into json string like as below

you data will be data: '{ "listkey":' + JSON.stringify(list) + '}',

$.ajax({ url: '@Url.Action("Search", "Result")', traditional: true, data: '{ "listkey":' + JSON.stringify(list) + '}', dataType: "html", type: 'POST', success: function (data) { alert("success"); }, error: function () { alert("fail"); } }); 

than try to see you are getting result you want or not

 [HttpPost] public ActionResult Result(List<string> listkey) { var n = listkey; return View(); }