什么是Ajax响应数据的最大尺寸是多少?尺寸、数据、最大、Ajax

2023-09-10 20:15:45 作者:barbarity(兽性)

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

I send request from asp.net page and then wait for response, calling GetCommand via SetInterval method:

    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(结果状态),我尝试提取我的数据:

In AjaxFinishedGet(result, status) I try to extract my data:

    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叫做:(

However, if Text size is more than 102330 bytes - instead of AjaxFinishedGet, AjaxFailedGet is called :(

我还没有发现任何信息的Ajax响应数据大小没有一些限制,也没有关于JavaScript的变量的大小,至少这样的变量可以保存1MB没有问题。其实文本可能包含1MB的数据...

I have not found any info neither about some limitation of ajax response data size nor about javascript variable size, at least such variable can hold 1MB without problems. Actually Text may contain 1MB of data...

问题出在哪里?

推荐答案

詹姆斯黑,我没有任何有关错误信息:

James Black, i have no any info about the error:

function AjaxFailedGet(XMLHttpRequest, textStatus, errorThrown) {
	$("#<%= tbResponse.ClientID %>").text(errorThrown);
	if (getCommand != null) {
		window.clearInterval(getCommand);
		$("#showajax").fadeOut("fast");
	}
}

errorThrown是空的。

网络服务器IIS7在Vista X32

WebServer is IIS7 on Vista x32

zazk, 谢谢,把这种检查是一个很好的点,我会使用这个标志的可靠性。然而,在给定的情况下,我不认为这可能是问题的原因是:响应输出不总是有效,当数据大小为102330和无效从102331开始(我使用新的String(X ,102330),所以它不能有任何特殊字符的问题或类似的东西)。

zazk, thanks, putting such check is a good point and i will use this flag for reliability. However, in the given case, i don't think it could be the reason of the problem: response output does work always, when data size is 102330 and doesn't work starting from 102331 (i am using new String('x', 102330), so it cannot be any special character problem or something like that).

 
精彩推荐