我正在使用jquery调用webmethod,该webmethod返回HTML的一部分,然后将其加载到div中。

它可以正常工作直到一定大小的块,然后完全不起作用。如果html块大于70KB,则似乎停止工作。

我正在使用的jQuery是:

 $(".letterBtn").live("click", function() {
    $("#divLoading").html('<img src="images/loading.gif" alt="Loading..." />');
    $.ajax({
        type: "POST",
        url: "Default.aspx/Search",
        data: "{sFor:" + "'" + this.id + "'" + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            $("#divOut").html(msg.d);
            $("#divLoading").html('');
        }
    });
});

网络方法与此类似
  <WebMethod()> _ Public Shared Function Search(ByVal sFor As String) As String
    Dim htmlString As String = "<div>some html</div>"
    Return htmlString
End Function

我似乎无法弄清楚为什么它不适用于较大的HTML块。有人有什么想法吗?谢谢!

最佳答案

找到我想要的内容后,默认设置似乎是100k,我在web.config文件中设置了以下内容。我想我现在将重新考虑html块,这似乎不是最好的解决方案。

<webServices>
<jsonSerialization maxJsonLength="10000000"/>
</webServices>

关于带有jQuery json的ASP.NET WebMethod,是否有大小限制?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4179986/

10-11 22:15
查看更多