简体   繁体   English

如何从AJAX向MVC中的控制器发送大量数据?

[英]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. 我正在使用AJAX将选定的复选框数据发送到控制器。 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. 目前,我正在发送55条记录,将来还会增加。 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. 我什至尝试过type:'POST' Still not working for huge data. 仍然无法处理海量数据。

I removed content type and changed my one to POST in both AJAX and Controller. 我删除了内容类型,然后在AJAX和Controller中都将其更改为POST。 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
        }
      }
    });
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM