if you change 2 things the script will run :
1. Declare p_labels as Object. Jquery.each() expects an Object,
not: an Array.
http://api.jquery.com/jQuery.each/
Code:
var p_labels=new Object(); // personal
var a_labels=new Object(); // address
var w_labels=new Object(); // work
2. The is an error inside the switch statement :
It should be
Code:
$.each(p_labels,function(i, value){
console.log('index: ' + i + ',value: ' + value);
document.writeln(i +" .. "+ value);
switch (i) {
case i = "First_Name" : //<<HERE! it's not a comparison so not case i == "First_Name"
alert("ho ho ho " + value);
break;
default :
alert("no match");
} // end switch
With this two modifs it runs here, althought I can't judge, if $.getJSON returns the data you want it to
EDIT: The api says "jQuery.each( collection, callback(indexInArray, valueOfElement) )" and a collection can be an array or an object.
So what I wrote before is not 100% correct.
BUT this example works with Object but it doesn't when you change the type to Array.
I guess this is caused by the way p_labels is created.
The example given in the Api explains this, I think:
Code:
<script>
var arr = [ "one", "two", "three", "four", "five" ];
var obj = { one: 1, two: 2, three: 3, four: 4, five: 5 };
jQuery.each( arr, function() {
$( "#" + this ).text( "Mine is " + this + "." );
// Will stop running after "three"
return ( this !== "three" );
});
jQuery.each( obj, function( i, val ) {
$( "#" + i ).append( document.createTextNode( " - " + val ) );
});
</script>