Note that there are some explanatory texts on larger screens.

plurals
  1. POTrack which JSON objects have been output
    primarykey
    data
    text
    <p>I'm outputting 20 or so JSON objects randomly by setting the index to a <code>randomNumber()</code> initially when the page is loaded. </p> <p>I'm refreshing each JSON object individually that has already been output on a timeInterval. To keep track of which JSON items have been output I am storing the index of each item into an array via <code>arrUsed.push[index]</code> </p> <p>Now trying to write the function that will <code>update()</code> each JSON objects individually and am currently stuck on how I can update the each div with the information from a new JSON object that has not already been output (pushed to the <code>arrUsed[]</code>).</p> <p>Here's the function I have so far:</p> <pre><code>function reloadItems() { var itemTotal = $('div.item').length; // Total number of items loaded initially var randomNumber=Math.floor(Math.random()*301) //returns number index = randomNumber; // Sets index to be used in JSON data to random number } </code></pre> <p>The array that contains the already output index's is declared globally: <code>arrUsed = [];</code> Each item that is output initially when the page load is being stored to the array fine, so that part is covered. It's a matter of choosing a random JSON object, checking to ensure it is not in the array/not been output already, and then updating the div on the page.</p> <p>Here's the <a href="https://stackoverflow.com/questions/14264647/use-json-data-outside-of-initial-ajax-call-access-leftover-json-data/14265131#comment19826534_14265131">previous question</a> that has led me to this point</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload