How to convert a json formatted string into a json array in javascript
<p>I am using the $.post() method to retrieve a json formatted string which looks like this:</p>

<pre><code>{elementid:10},{elementid:11},{elementid:12},{elementid:14},{elementid:15}
</code></pre>

<p>In the success callback function of $.post(), I would like to loop the values of this json formatted string but I can't figure out how to do it.</p>

<pre><code>  // data returns {elementid:10},{elementid:11},{elementid:12},{elementid:14}, etc.

  $.post('form.php',

        {'postvalues' : input_ids},

        function(data){

              var elements = Array();

              elements = [data];

              for(var i=0; i&lt;elements.length; i++) {
                    var value = elements[i]['elementid'];
                    alert('value = '+value);
              }
  });
</code></pre>

<p>When I do this, instead of getting <code>value = 10, value = 11, value = 12</code>, etc. in the alert box, 
I get <code>value = undefined</code></p>

<p>What must I change in the format of the variable 'data' so that it will be interpreted as array values and not a string?</p>

<p>thanks for your help</p>
