简体   繁体   English

无法使用Ajax发送更大的json(array)数据

[英]unable to send bigger json(array) data using ajax

I am facing a peculiar problem while sending large data via ajax in mvc.When I send around 500 amount of data its working but when its large its showing an error 我在MVC中通过Ajax发送大数据时遇到一个特殊的问题。当我发送大约500数据时,它的工作正常,但是当它大时显示错误

Uncaught TypeError: Cannot read property 'length' of undefined 未捕获的TypeError:无法读取未定义的属性“ length”

I dont understand why its happening My codes are 我不明白为什么会发生我的代码是

//Reading data from table 
  var imeiUpload = [];

 $('#tblDatas tbody').find("tr").each(function(row, tr) {

        imeiUpload.push({
            Model: $(tr).find('td:eq(0)').text(),
            Color: $(tr).find('td:eq(1)').text(),
            Barcode: $(tr).find('td:eq(2)').text(),
            Barcode2: $(tr).find('td:eq(3)').text(),
            UpdatedBy: $(tr).find('td:eq(4)').text(),
        });
    });
    //then ajax code

 $.ajax({
        url: ' @Url.Action("InsertImeidata", "Admin")',
        type: 'Post',
        data: JSON.stringify({ imeiModelUpload: imeiUpload }),
        dataType: 'json',
        async: false,
        contentType: 'application/json',
        success: function (data) {


        },
        error: function (result, textStatus, jqXHR) {

            //return false;
        }
    });

Thanks For Help 感谢帮助

At last I found that there was no problem in my ajax or json code everything is fine , The problem was the size of the json data i am sending .And there is a default size in Asp.net application for sending json data 最后我发现我的ajax或json代码没有问题,一切都很好,问题是我正在发送的json数据的大小.Asp.net应用程序中有一个默认大小用于发送json数据

So what I found i have to increase the default size of json data in my application so i added the below lines 所以我发现我必须在应用程序中增加json数据的默认大小,所以我添加了以下几行

<appSettings> 
<add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>

then It started working,now i can send big amount of json array. 然后它开始工作,现在我可以发送大量的json数组。

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

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