I'm having difficulty trying to return a multi-demensional array using Javascript Prototype's Hash Object. I have been able to return the values of the following associative php array using JSON and Javascript Prototype's Hash Object:
php array
$player = array(
'PlayerName' => 'Ron Artest',
'Position' => 'Forward',
'Height' => '6-7',
'Weight' => '260',
'College'=> 'St. Johns');
Javascript Code used to return values of array:
var request = new Ajax.Request('jsonEncode.php',
{
onSuccess: function(request)
{
var emptyAssociativeArray = request.responseJSON;
emptyAssociativeArray= (Object.isArray(emptyAssociativeArray) && !emptyAssociativeArray.length) ? {} : emptyAssociativeArray;
$H(emptyAssociativeArray).each(function(pair) {
$('workaroundOutput').insert('<div>' + pair.value + '</div>');
});
},
method: 'get',
parameters:
{
team: 'LA Lakers'
}
});
BUT, when I try to return the following I run into a snag.
$player = array(
array(
'PlayerName' => 'Ron Artest',
'Position' => 'Forward',
'Height' => '6-7',
'Weight' => '260',
'College'=> 'St. Johns'),
array(
'PlayerName' => 'Kobe Bryant',
'Position' => 'Guard',
'Height' => '6-6',
'Weight' => '205',
'College'=> 'Lower Marion High Sc')
);
PLEASE HELP!!