views:

554

answers:

2

I am working on an application using the YUI DataTable and my result set is rather large (2,000+ rows) which takes YAHOO.lang.JSON.parse() about 5-6 seconds to parse.

During this time the browser becomes completely unusable.

Does anyone know of a way to grab a JSON response and parse it into JS with timeouts? Say... 100 rows every 50-100ms instead of parsing the whole thing at once and locking up the browser for the entire duration?

+5  A: 

Maybe you should use an other format. Take a look at Building Fast Client-side Searches and read how Flickr solved a similar problem.

Gumbo
+1  A: 

You would need to fetch it in chunks with several request then merge the data manually on the client.

If your data isn't complex you might wanna try just evaling the json-response yourself. Most JSON-parsers have a lot more logic to it than you find nessecary.

var data = eval('(' + response + ')');

See how long that takes.

jishi