I have an object array like the following.
var array=[
{
Name:"name",
Address:"address",
Files://array of files
},
{
Name:"name",
Address:"address",
Files://array of files
}
];
I need to pass the array through ajax and retrieve it on mvc controller. I am not getting both data and file at the same time as array in controller.
I have used formData in case of single object.But in the case of array I don't know how.Anyone please help
my code.. model..
public class DataModel{
public string Name{get;set;},
public string Address{get;set;},
public HttpPostedFileBase[] Files{get;set;}
}
Controller..
[HttpPost]
public JsonResult AddData(List<DataModel> data)
{
//code
}
ajax//
$.ajax({
type: "POST",
url: '/Mydata/AddData',
data: {data:array},
contentType: false,
processData: false,
dataType: "json",
success: function (json) {
//some function
}
});