Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript while loop and inner html
    primarykey
    data
    text
    <p>I can't figure this one out. Why is this breaking down? My alert statements show me clearly that the elements are all coming in but if i replace them with the inner html line it stops after the first iteration.</p> <pre><code>while(i&lt;6) { document.getElementById("cell-"+i).innerHTML = out[i] ; i++ ; } </code></pre> <p>below variation shows me that all elements come in and the cell names are correctly constructed:</p> <pre><code>while(i&lt;6) { alert("cell-"+i) alert(out[i]) i++ ; } </code></pre> <p><strong>[EDIT]</strong></p> <p>ok judging from your feedback it's not a syntax or loop construction issue which i hoped could be easily fixed. Here's more background:</p> <p>I'm using this to populate a table with parsed data from an Ajax call. The data format is JSON. It's a little search engine for photos. IF my first search is for keywords that can be found the table is populated. If HOWEVER i first search for some gibberish (e.g.: dfadfasfad), no results are retrieved (so far so good). If i THEN search for a word that would retrieve results, the whole thing breaks down. So IT IS a Ajax problem after all? Sorry, the code is way too long to post here i think. If my problem rings a bell let me know. Else no worries.</p> <p><strong>[EDIT2]</strong></p> <p>from Firebug:</p> <pre><code>document.getElementById( display(out=["Colorful Drinks by the ...a0c1a.jpg"&gt;&lt;br /&gt;&lt;br /&gt;", "Peru-100526-473&lt;br /&gt;&lt;i...f7908.jpg"&gt;&lt;br /&gt;&lt;br /&gt;", "AR6E0549&lt;br /&gt;&lt;img src=...8bfea.jpg"&gt;&lt;br /&gt;&lt;br /&gt;", 3 more...])AjaxUpdater.js (line 128) onResponse()AjaxUpdater.js (line 65) [Break On This Error] document.getElementById("cell-"+i).innerHTML = out[i] ; </code></pre> <p><strong>[EDIT3]</strong></p> <p>ok i'm getting closer. it seems that the innerHTML assignments modify the page structure</p> <p>BEFORE</p> <p><img src="https://i.stack.imgur.com/x8cc9.jpg" alt="enter image description here"></p> <p>AFTER</p> <p><img src="https://i.stack.imgur.com/0U2Ir.jpg" alt="enter image description here"></p>
    singulars
    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.
    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