0

I have an array of objects in my jquery function like this:

0: name='N1', value='V1'

1: name='N2', value='V1'

2: name='N3', value= file

3: name='N4', value= file

which "file" is a file object, from a file input.

I want to send this array (mix of files and strings) to an MVC controller in asp.net by Ajax.

I don't know how my controller signature should be and how to send this array by Ajax.

Update:

this is my code that generates this array:

var formObj = $('#TaskForm');
var data = formObj.serializeArray();
var formdatamodel =  JSON.parse(JSON.stringify(data));

$.each(formObj.find("input[type='file']"), function(i, tag) {
  $.each($(tag)[0].files, function(i, file) {
    var temp = {name:tag.name, value: file };
    formdatamodel.push(temp);
  });
});

console.info(formdatamodel);

Thanks for your help

Hadelo
  • 53
  • 7
  • 1
    update your code what you have implement and error if you are facing any issue – saurabh kamble Dec 14 '15 at 05:42
  • You need to use `FormData` is your posting the data using ajax. Refer [this answer](http://stackoverflow.com/questions/29293637/how-to-append-whole-set-of-model-to-formdata-and-obtain-it-in-mvc/29293681#29293681) to get you started –  Dec 14 '15 at 06:20

0 Answers0