JS - Splitting a string and looping through results
<p>In JS, I'm having trouble working out how to split a string coming from an AJAX call.</p>

<p>This is what I have so far:</p>

<pre><code>xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
{
feedUpdateResponse = xmlhttp.responseText;
/////...split script.../////
}
}
xmlhttp.open("GET","https://myDomain.com/myScript.aspx",true);
xmlhttp.send();
</code></pre>

<p>Where you have /////...split script...///// in my script above, I need to add a little function that splits the string returned from my AJAX call.</p>

<p>The string simply contains names of DIVs, like this:</p>

<pre><code>feedUpdateResponse = "div1/div2/div3/div4"
</code></pre>

<p>I would like to first split the string by its slashes (/) and run a loop through the different values and do stuff to those elements on my page.</p>

<p>To give an idea of what I need to achieve, I have given this example which is a mix of ASP &amp; JS - it's the only way I can possibly describe it (and show that I've had an attempt) :)</p>

<pre><code>MyArray = Split(feedUpdateResponse,"/")
For Each X In MyArray
documentGetElementById('updateAvailable_'+x).style.visibility="visible";
Next
</code></pre>

<p>On my page I have an ASP script that produces jquery carousels, all contained by separate DIVs. The DIVs are named DIV1, DIV2 etc. Inside DIV1, for example, is a text element called <code>updateAvailable_div1</code> which will alert the user "There are new photos available for this feed, please click the refresh button".</p>

<p>Could somebody please explain to me how I can change my example above to work in JS? Just need to split the string into an array and loop through the split values...</p>
