简体   繁体   English

在IE中解析非常大的JSON字符串会导致问题

[英]Parsing very large JSON strings in IE causing problems

I'm parsing a 2MB JSON string in IE8. 我在IE8中解析2MB JSON字符串。 The JSON.Parse line is taking a little while to return and IE8 shows a message asking the user if they want to abort the script. JSON.Parse行需要一段时间才能返回,并且IE8显示一条消息,询问用户是否要中止脚本。

Is there any way I can suppress this message? 有什么办法可以禁止显示此消息? (or somehow speed up JSON.Parse) (或以某种方式加快JSON.Parse的速度)

I know about Microsoft KB175500 , however this is not suitable as my target users will not have administrator access to make the registry modifications on their SOE machines. 我知道Microsoft KB175500 ,但是这不适合我的目标用户,因为他们的目标用户将没有管理员权限,无法在其SOE计算机上进行注册表修改。

I had this same question. 我有同样的问题。 Apparently there is no way to suppress the message, but there are tricks to make IE think it's still working by using an asynchronous iteration pattern (dead link, view comments below). 显然没有办法抑制该消息,但是有一些技巧可以使IE通过使用异步迭代模式使它认为它仍在工作(无效链接,请在下面查看评论)。

This comes from an answer to one of my questions: loop is too slow for IE7/8 这来自对我的一个问题的解答: IE7 / 8的循环太慢

If the browser is unhappy with how long the JSON parser is taking, there are only four choices here I know of: 如果浏览器对JSON解析器需要花费多长时间不满意,那么我在这里只有四个选择:

  1. Get a faster JSON parser that doesn't take so long. 获得不需要那么长时间的更快的JSON解析器。
  2. Break up your JSON data into smaller pieces so you are only parsing smaller pieces at once. 将您的JSON数据分解成较小的部分,以便您一次只能解析较小的部分。
  3. Modify a JSON parser to work in chunks so it can parse part of the data in one chunk, then on a short timeout, parse the next chunk, etc... This will prevent the browser prompt, but is probably a lot of work to write/modify a JSON parser that works this way. 修改JSON解析器以大块形式工作,以便它可以将一个大块中的部分数据解析,然后在很短的超时时间内解析下一个大块,依此类推...这将阻止浏览器提示,但可能需要做很多工作编写/修改以这种方式工作的JSON解析器。
  4. If you can be sure the content is safe, then you could see if using eval instead of a JSON parser works around the issue. 如果可以确定内容安全,则可以查看使用eval代替JSON解析器是否可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM