Jump to content

JSON, Loop and updating variables at same time


intellix

Recommended Posts

Hey guys... quick question

 

I have jQuery using JSON to pull in aload of data...

Within the JSON request, when it returns data, I have a loop that adds stuff to an object and then updates the page... It uses a variable I want to update at the same time.

 

If I make the request and I start playing with the site, I want the function at the end of the loop to use the latest data (as JSON isn't instant and I don't want to lock the page from the user updating it)... Can I update the variable whilst the JSON request, loop is running and then when it gets to the end of it, the variable will be updated? Or does JavaScript work on a queue sort of basis where it will finish the JSON request, loop first until I can start updating variables that will be used at the end of it all?

 

Thanks, Dom

Link to comment
Share on other sites

Also in terms of performance... Say if I have a 250kb JSON script pulled and put into an object like:

 

var $largeData = jsondata;

 

Once I've done with it, do you think its good to set it to null or something to free memory? Or is this done automatically and not needed?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.