parkerblush
New Member
How can I get the value of \[code\]'weight'=>$item->ItemAttributes->PackageDimensions->Weight\[/code\] if i use \[code\]+data['weight'][0]\[/code\] It wont display any output, and in firebug response tab the value contains like this \[code\]"weight":{"@attributes":{"Units":"hundredths-pounds"},"0":"420"\[/code\]. The first value of the array I can retrieve it with no problem with this line of code \[code\]+data['asin'][0]\[/code\] and in firebug response tab the value is like this \[code\]{"asin":{"0":"1585161519"}\[/code\]. My problem is retrieving the second arrayHere's the js code:\[code\]$.ajax({ url: 'get-products.php', type: 'post', datatype: 'json', data: { category: $('.category').val().trim(), keyword: $('.keyword').val().trim() }, success: function(data){ var toAppend = ''; if(typeof data =http://stackoverflow.com/questions/12599398/=="object"){ for(var i=0;i<data.length;i++){ toAppend += '<tr><td>'+data['asin'][0]+'</td><td>'+data['weight'][0]+'</td></tr>; } $('.data-results').append(toAppend); } } });\[/code\]Here's my php code:\[code\] foreach($xml->Items->Item as $item){ $items_from_amazon[] = array('asin'=>$item->ASIN, 'weight'=>$item->ItemAttributes->PackageDimensions->Weight); } echo json_encode($items_from_amazon);\[/code\]