Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript explode issue
    primarykey
    data
    text
    <p>I am running an ajax query and returning JSON and one of the results is a field named <code>image.comment</code> e.g.</p> <pre><code>test~63~Dave Sanders~http://graph.facebook.com/998433599/picture?type=large~Dave Sanders~9 minutes ago </code></pre> <p>I'm using <code>~</code> as a separator</p> <p>There maybe be multiple similar sets of data separated by <code>----</code> in <code>image.comment</code> so to parse the data and add it to the DOM i'm using:</p> <pre><code>if(image.comment){ html += '&lt;div class="msgs_holder'+image.list_id+'"&gt;'; // split comment at ---- var comString = image.comment; var comArray = comString.split("----"); var lengthArray = comArray.length, element = null; for (var i = 0; i &lt; lengthArray; i++) { element = comArray[i]; // split indiv comment at ~ var comUserString = element; var comUserArray = comUserString.split("~"); html += '&lt;div class="msgs_row"&gt;&lt;div class="msgs_pic"&gt;&lt;a href="/'+comUserArray[4]+'"&gt;&lt;img src="'+comUserArray[3]+'"&gt;&lt;/a&gt;&lt;/div&gt;'; html += '&lt;div class="msgs_comment"&gt;&lt;a href="/'+comUserArray[4]+'" style="text-decoration:none;"&gt;&lt;span class="msgs_name"&gt;'+comUserArray[2]+'&lt;/span&gt;&lt;/a&gt; '+comUserArray[0]+'&lt;br&gt;&lt;span class="msgs_time" title="'+comUserArray[5]+'"&gt;'+comUserArray[5]+'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;'; } html += '&lt;/div&gt;'; } </code></pre> <p>But the page fails to load and firefox firebug tells me: <code>allocation size overflow</code></p> <p>This only happens on rows of the JSON where there is data in <code>comment</code> column</p> <p>I suspect some maybe infinite looping but can't see it</p> <p>I've checked the query and it runs fine so not that</p> <p>Is this the best way to explode in js?</p> <p>Any ideas?</p> <p><strong>MORE INFO</strong> The reason I'm doing it this way is it's a piece of a much bigger query. Images loaded to a page with comments under each image. So I'm loading the comments into a column to be parsed for display.</p> <p>Example:</p> <pre><code>Image 1 Image 2 Image 3 etc etc etc hey i think its great! hey back! me too I'm not sure </code></pre> <p><strong>MORE INFO 2</strong> This data is taken from a MySQL query e.g</p> <pre><code>select w.img_width, w.img_height, w.prod_pic_url as preview3, GROUP_CONCAT(ww.comment,'~', h.user_id,'~', h.name,'~', h.live_prof_pic,'~', h.twovo_url,'~', time_ago(ww.dateadded) SEPARATOR '----') AS comment from tableName where blah=blah </code></pre> <p>GROUP_CONCAT is the comments section mentioned above</p> <p>So, to use JSON for data within data, is that possible? If so how?</p> <p>Example returned data:</p> <pre><code>"preview3":"http:\/\/myurl.com\/wish_images\/production\/3578.jpg","comment":"test~63~Dave Sanders~http:\/\/graph.facebook.com\/Dave Sanders\/picture?type=large~Dave Sanders~39 minutes ago"},{"item_id":"3559","numComms":"0","numLikes":"0"... etc etc </code></pre>
    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.
 

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