[英]Is there a limit on the size of the string passed to jQuery.append()
I wrote a basic program in Angular that uses the router functionality to present two pages as a single page application. 我在Angular中编写了一个基本程序,它使用路由器功能将两个页面呈现为单页面应用程序。 So far, that is all it does.
到目前为止,就是这样。 I have a page that contains two buttons for navigation, and a wrapper div (ng-view) that is filled with the content of the two pages when the respective button is clicked.
我有一个页面,其中包含两个用于导航的按钮,以及一个包装div(ng-view),当单击相应的按钮时,该页面填充了两个页面的内容。
When I try to load the larger of the two pages, I get the following error: 当我尝试加载两个页面中较大的一个时,我收到以下错误:
SyntaxError: Unexpected token <
This error is thrown from angular.js:11594 (I am using version 1.3.9). 从angular.js:11594抛出此错误(我使用的是版本1.3.9)。 After debugging, I found that an exception is thrown in jQuery, from the code:
调试之后,我发现jQuery中抛出了一个异常,代码如下:
this.empty().append( value );
I looked at the input parameter 'value', and it is very large. 我查看了输入参数'value',它非常大。 It contains more than 11,000 lines, and is 1.59 MB large.
它包含超过11,000行,大1.59 MB。
I ran the input string in an html format checker ( http://www.freeformatter.com/ ). 我在html格式检查器( http://www.freeformatter.com/ )中运行输入字符串。 The format is fine and there is no extra opening tag.
格式很好,没有额外的开放标记。
Is it possible that jQuery's method cannot handle such a large string? 是否有可能jQuery的方法无法处理如此大的字符串? I searched Google for such a limitation, but all I could find was suggestions for applying limitations using jQuery, and the documentation ( http://devdocs.io/jquery/append ) did not mention such a limit.
我在Google上搜索了这样的限制,但我发现的只是使用jQuery应用限制的建议,文档( http://devdocs.io/jquery/append )没有提到这样的限制。
Notes: 笔记:
Thanks. 谢谢。
First limit you will face is that if the string's over 512 bytes then the dom fragments created by it aren't cached. 你要面对的第一个限制是,如果字符串超过512个字节,那么它创建的dom片段不会被缓存。 Next limit is the limit of .innerHTML in the browser is.
下一个限制是浏览器中.innerHTML的限制。 But it is pretty huge (high)... But while appending lots of content you will face huge lags (It will take very long time to load propably).
但是它非常巨大(高)......但是在附加大量内容的同时,你将面临巨大的滞后(可能需要很长时间才能加载)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.