I need to read each value from a json result i request to a controller action. this is my client side.
$.ajax({
type: "POST",
url: "List",
data: { firstArray: arrayCountries, secondArray: arrayLang },
success: function (result) {
//here i need each value from json, but it's not working for me
},
dataType: "json",
traditional: true
});
Ok now i use this way because i need to send 2 javascript arrays and after finding a lot this way works for me.
And this is my server side. According to How can I post an array of string to ASP.NET MVC Controller without a form? i have created this.
public ActionResult List(List<String> firstArray, List<String> secondArray)
{
//But here i need a list of sections, so i call a method for that
var sections = SomeClass.getSections(fistArray, secondArray);
//And return the json with the collection
return Json(sections, JsonRequestBehavior.AllowGet);
}
Now this is my getSections Method
public static IEnumerable getSections(List<String> firstArray, List<String>secondArray)
{
entities db = new entities();
var result = from values in db.Sections
where ...
select new SectionsModel{ // do something };
return result.OrderBy(p => p.Description);
}
Now im getting well json in client side but i don't know how to acces it, and how can i get each value from it ? ... thanks in advance.