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!
As we know, the property of a static method “We can invoke a static method using it's class name without creating an object of this specific class”. This is the reason it's necessary to declare WebMethod as a static method.
The WebMethod attribute is added to each method we want to expose as a Web Service. ASP.NET makes it possible to map traditional methods to Web Service operations through the System. Web. Services. WebMethod attribute and it supports a number of properties that control the behavior of the methods.
Client-Side - Using ajax() to Call Data Methods delegate('tr', 'click', function () { var req = $. ajax({ type: "POST", url: "AspAjax. aspx/GetUserDetails", contentType: "application/json; charset=utf-8", dataType: "json", data: "{ id: " + id + "}" }); req. done( /* Add function here to handle success case */ ); req.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With