开发者

ASP.NET WebMethod with jQuery json, is there a size limit?

开发者 https://www.devze.com 2023-01-25 15:56 出处:网络
I\'m calling a webmethod using jquery, the webmethod returns a chunk of HTML that\'s then loaded into a div.

I'm calling a webmethod using jquery, the webmethod returns a chunk of HTML that's then loaded into a div.

It works fine up until a certain size of chunk then it's doesn't work at all. It seems to stop working if the chunk of html is above 70KB.

The jQuery I'm using is:

 $(".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('');
        }
    });
});

The webmethod is similiar to this

  <WebMethod()开发者_开发技巧> _ Public Shared Function Search(ByVal sFor As String) As String
    Dim htmlString As String = "<div>some html</div>"
    Return htmlString
End Function

I can't seem to figure out why it doesn't work for larger HTML chunks. Does anybody have any ideas? thanks!


found what I was after, the default setting seems to be 100k, I set the following in my web.config file. I think I'll rethink the html chunks now, it's doesn't seem like the best solution.

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

精彩评论

暂无评论...
验证码 换一张
取 消