Hi stackers,
I'm trying to take a jSON encoded string out of my database and loop through the items but I'm having some difficulty. Here's the string in the database:
["volunteers","seat_dedication_program","memberships"]
And here is the code:
//Looks for _checkbox when looping through my database fields (object dbVals) and turns it into a true jQuery array if it finds it.
if( key.search(/_checkbox/i) > 0 ) var arr = $.makeArray(dbVals[key]);
//If it is an array, loop through the array values and show them
if($.isArray(arr)==true){
$.each(arr, function(i, n){
alert(i + " : " + n);
});
}
What I want is this:
//alert
0 : volunteers
//alert
1 : seat_dedication_program etc...
What I'm getting is this:
//alert
0 : ["volunteers","seat_dedication_program","memberships"]
I think I've included all relevant data. Can anyone help me figure out why this is happening?
Thanks.