Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ajax响应数据的最大大小是多少?_Ajax_Size_Response_Max - Fatal编程技术网

ajax响应数据的最大大小是多少?

ajax响应数据的最大大小是多少?,ajax,size,response,max,Ajax,Size,Response,Max,我从asp.net页面发送请求,然后等待响应,通过SetInterval方法调用GetCommand: function GetCommand(id, sid) { getCommandResponse = $.ajax({ type: "POST", async: true, url: "../WebServices/TSMConsole.asmx/GetCommand", data: "{'param' : '"

我从asp.net页面发送请求,然后等待响应,通过SetInterval方法调用GetCommand:

    function GetCommand(id, sid) {
    getCommandResponse = $.ajax({
        type: "POST",
        async: true,
        url: "../WebServices/TSMConsole.asmx/GetCommand",
        data: "{'param' : '" + id + "', 'sid' : '" + sid + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(result, status) {
            AjaxFinishedGet(result, status);
            getCommandResponse = null;
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            AjaxFailedGet(XMLHttpRequest, textStatus, errorThrown);
            getCommandResponse = null;
        }
    });
}
在AjaxFinishedGet(结果、状态)中,我尝试提取数据:

    function AjaxFinishedGet(xml, status) {
    endDate = new Date();
    if (xml.d.IsPending == 'false' || endDate - startDate > timeoutMSec) {
        if (getCommand != null) {
            window.clearInterval(getCommand);
            getCommand = null;
            WriteGetCommand(xml.d.Text);
            $("#showajax").fadeOut("fast");
        }
    }
}
但是,如果文本大小超过102330字节-而不是AjaxFinishedGet,则调用AjaxFailedGet:(

我没有发现任何关于ajax响应数据大小限制或javascript变量大小的信息,至少这样的变量可以容纳1MB而没有问题。实际上文本可能包含1MB的数据


问题出在哪里?

好吧,多个请求可能会导致错误,也许一个好的解决方案是验证当前没有活动的请求

var loading = false;
function GetCommand(id, sid) {
    if (loading) {return false;}
    loading =  true;
        getCommandResponse = $.ajax({
         ....
         ....
        });

}

function AjaxFinishedGet(xml, status) {
    loading = false;
    ...
    ...
}

詹姆斯·布莱克,我没有关于错误的任何信息:

function AjaxFailedGet(XMLHttpRequest, textStatus, errorThrown) {
    $("#<%= tbResponse.ClientID %>").text(errorThrown);
    if (getCommand != null) {
        window.clearInterval(getCommand);
        $("#showajax").fadeOut("fast");
    }
}
函数AjaxFailedGet(XMLHttpRequest、textStatus、errorshown){
$(“#”)文本(错误抛出);
if(getCommand!=null){
clearInterval(getCommand);
$(“#showajax”).fadeOut(“快速”);
}
}
  • ErrorRown是空的
Web服务器是Vista x32上的IIS7

扎兹克,
谢谢,进行这样的检查是一个很好的观点,为了可靠性,我将使用这个标志。但是,在给定的情况下,我不认为这可能是问题的原因:当数据大小为102330时,响应输出总是工作的,并且从102331开始就不工作(我使用的是新字符串('x',102330),因此它不能是任何特殊字符问题或类似的问题)。

在.NET的web.config文件中有一个默认设置为4mb

<system.web>
<httpRuntime maxRequestLength="4096" />
</system.web>


因为
maxRequestLength
是一个INT,所以理论上的最大值是INT max值,即2147483647

我刚刚遇到了一个严重的错误,我跟踪到了从AJAX调用返回的字符串的长度。它大约是63639(iirc),接近ushort的极限(同样,iirc!)(我猜iis附加了自己的东西来弥补字符限制的其余部分)


我设法从字符串中的html中去掉所有样式,并在客户端收到时通过JQuery将其追加!:)

抛出了什么错误?您使用的是哪个Web服务器?