Halim
Halim

Reputation: 95

How to Send huge amount of data from AJAX to controller in MVC?

I am using AJAX to send selected check box data to controller. For few records its working properly, but for bulk and heavy record it not sent any data to controller. How to fix this? Currently I am sending 55 records, it will increase in future. Kindly help. Coding below.

function Continue() {
  var arrSchd=[];
  var selectedIds="";
  var table = $('#Details').DataTable();

  table.$('input[type="checkbox"]:checked').each(function(index,val){
    var SchdId=$(this).val();
    arrSchd.push(SchdId);
  })

  if(arrSchd.length!=0){
    selectedIds=arrSchd.toString();
    WaitCursorStart();
    $.ajax({
      url: "/MultipleEdit/MultiEditChange",
      data:{"selectedIds":selectedIds,"STime": $('#STime').val(),"ETime": $('#ETime').val()},
      type: 'GET',
      contentType: 'application/json;',
      dataType: 'json',
      success: function (result) {
        if (result.success == 'success') {
          //some process here
        } else {
          //some process here
        }
      }
    });
  }
}

I even tried with type:'POST' also. Still not working for huge data.

Upvotes: 0

Views: 1625

Answers (1)

Halim
Halim

Reputation: 95

I removed content type and changed my one to POST in both AJAX and Controller. It's working.

My updated answer below

function Continue() {
  var arrSchd=[];
  var selectedIds="";
  var table = $('#Details').DataTable();

  table.$('input[type="checkbox"]:checked').each(function(index,val){
    var SchdId=$(this).val();
    arrSchd.push(SchdId);
  })

  if(arrSchd.length!=0){
    selectedIds=arrSchd.toString();
    WaitCursorStart();
    $.ajax({
      url: "/MultipleEdit/MultiEditChange",
      data:{"selectedIds":selectedIds,"STime": $('#STime').val(),"ETime": $('#ETime').val()},
      type: 'POST',
      dataType: 'json',
      success: function (result) {
        if (result.success == 'success') {
          //some process here
        } else {
          //some process here
        }
      }
    });
  }
}

Upvotes: 1

Related Questions