You are hitting the max size of your json payload so your serializer is throwing an exception. This doesn't have anything to do with your JavaScript, it's all in your backend.
You need to set the MaxJsonLength
property on your JavaScriptSerializer
settings
The maximum length of JSON strings. The default is 2097152 characters,
which is equivalent to 4 MB of Unicode string data.
Example: serializer.MaxJsonLength = <something big enough to support your payload>
;
If that still doesn't work, update your web.config
with something similar:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
It may also help to determine how big your payload actually is before returning it.
https://docs.microsoft.com/en-us/dotnet/api/system.web.script.serialization.javascriptserializer.maxjsonlength?view=netframework-4.8
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…