1

I'm parsing a 2MB JSON string in IE8. 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.

Is there any way I can suppress this message? (or somehow speed up 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.

Ozzah
  • 10,386
  • 15
  • 69
  • 112
  • is your JSON from 3rd party or your own host ? –  Sep 06 '11 at 04:36
  • It's a local file. The JSON string is already stored in a variable in JS - the line which is causing trouble is the line which parses the string variable into a javascript object. – Ozzah Sep 06 '11 at 04:38
  • so does your user uploads the file ? –  Sep 06 '11 at 04:39
  • @Ozzah - I would limit the size of the response. Maybe you could page the results somehow. – ChaosPandion Sep 06 '11 at 04:41
  • so by AJAX i am assuming its from your own sever, you might consider lazy load then. create multiple objects. PS. it's more of optimization so the code will help alot. –  Sep 06 '11 at 04:42

2 Answers2

3

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).

This comes from an answer to one of my questions: loop is too slow for IE7/8

Community
  • 1
  • 1
Jacksonkr
  • 29,242
  • 36
  • 164
  • 265
  • Well that's dumb. I searched google 'parallel iteration javascript' for and found http://stackoverflow.com/questions/8413857/whats-the-smartest-cleanest-way-to-iterate-async-over-arrays-or-objs – Jacksonkr Jul 19 '13 at 18:11
0

If the browser is unhappy with how long the JSON parser is taking, there are only four choices here I know of:

  1. Get a faster JSON parser that doesn't take so long.
  2. Break up your JSON data into smaller pieces so you are only parsing smaller pieces at once.
  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.
  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.
demongolem
  • 8,796
  • 36
  • 82
  • 101
jfriend00
  • 580,699
  • 78
  • 809
  • 825