Click here to Skip to main content
14,870,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using below code for collecting data and Ajax call:

var childArr = [];

   var fileUploadControl = $('#File_Arr').get(0);

   var files = fileUploadControl.files;

   var formData = new FormData();

   for (var i = 0; i < files.length; i++) {
       formData.append('File_Arr', files[i]);
   }

   var children = $('#file-container table').children('tbody');
   var test1 = [1, 2, 3, 4];
   var test2 = [5, 6, 7, 8];
   $(children).each(function (index, item) {
       var count = $(item).children().length - 1;
       childArr.push(count);
   });

   for (var i = 0; i < childArr.length; i++) {
       formData.append('tableRowCount', childArr[i]);
   }


   $.ajax({
       url: "@Url.Content("~/Search_Replace_/UploadFile")",
       type : "POST",
       data: formData,
       processData: false,
       contentType: false,
       success: function (msg) {
           console.log('Success!');
       }
   });


What I have tried:

I have tried to catch the Ajax call in controller by using below code:

[HttpPost]
    public ActionResult UploadFile(int[] tableRowCount, HttpPostedFileBase[] File_Arr)


but I am getting null value in tableRowCount array. Can someone help with this?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900