ajax错误500&MVC中的内部服务器错误 [英] ajax error 500 & Internal Server Error in MVC

查看:68
本文介绍了ajax错误500&MVC中的内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ajax方法来调用控制器并获取数据,并将其转换为json或list并设置一个jQuery DataTable .用1000条记录可以正常工作,但是当我获取5000条以上的记录时,ajax方法会给我:

I used ajax method to call the controller and fetch the data and convert it to json or list and set a jquery DataTable. With 1000 records it's working fine, but when I fetch more than 5000 records, ajax method gives me:

500内部服务器错误

500 Internal server error

这是我的代码:

 $('#btnAllData').click(function () {

    $.ajax({
        url: 'PartMaster/GridLoad',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (Result) {
            debugger;
            var pageload = Result.split('|');
            var status = (pageload[0])

            if (status == "ERROR") {
                Error(pageload[1]);

            }
            else {
                var Partdetails = (pageload[0]);
                //var LocDetails = JSON.parse(pageload[2]);

            }

            //gridDetails(status1);

        },

        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
        }
    });


});

推荐答案

  1. 检查数据库要花多少时间才能返回数据.
  2. 设置Web响应的长度(您可以使用来在web.config中调整JSON响应的大小.)

  1. check how much time your database is taking to returning data.
  2. Set length of web response ( You can adjust the JSON response size in the web.config with ).

<configuration>
<system.web.extensions>
    <scripting>  
         <webServices>                                                   
             <jsonSerialization maxJsonLength="1000000" />                 
         </webServices>
    </scripting>
</system.web.extensions>
</configuration>

这篇关于ajax错误500&amp;MVC中的内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆