Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking a step-by-step ajax request
    primarykey
    data
    text
    <p>I'm thinking about how to change a content of a div dynamically. So, here is the ajax request:</p> <pre><code>$.ajax({ url:'/foos', cache: false, type: 'get', }).done( function( foo_array ) { for( foo in foo_array ) { $('#foo-container').append('&lt;div class="foo-var"&gt;'+foo+'&lt;/div&gt;'); } }); </code></pre> <p>So bassically, this ajax append all foo-var divs from the server, but if the foo_array is too long or a big very big array there is a problem because i think that takes more and more time depending on the foo_array's length</p> <p>How can I append one by one??, how can I query one by one and append in foo-container instead query all foos and make an iteration??</p> <p>I want to do something like this</p> <pre><code>if(foos.hasNext()){ $.ajax..... append(foo)....} </code></pre> <p>foos is an array made by many documents from a mongodb database, so I cant get the length of the array because depends of the query's find() arguments..</p> <p>I'm using nodejs, mongodb, expressjs and jquery for ajax</p> <p>Sorry for my bad English, and thank you all!</p> <p>EDIT 2</p> <p>this is an example of the data in mongodb</p> <pre><code>{category:1, name:'robert',personal:true,option:'class'} {category:1, name:'alfredo',personal:false,option:'class'} {category:4, name:'ricardo',personal:true,option:'class'} {category:1, name:'genaro',personal:true,option:'class'} {category:2, name:'andres',personal:false,option:'class'} {category:1, name:'jose',personal:true,option:'class'} db.collection.find({personal:true}) // gives me 4 documents db.collection.find({option:'class'}) // gives me 6 documents db.collection.find({category:4}) // gives me 1 document </code></pre> <p>i dont know how many documents can get from the cursor, i need to charge one by one cause there are 5097841 documents in the databse so, ajax can take long time to return all the information, i need to query one by one if hasNext() in the cursor of mongodb</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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