Monday, June 1, 2009

[jQuery] json indexing not working for me

the basics: php, jquery, javascript

server side ajax_member.php (bascially try to send what I get back to the client,.. for testing!!!)
<?php
$arr = $_GET;
$myjson = json_encode($arr);
echo $myjson;
?>

client side:

var data =
{
"mybutt" : "is so big!",
"member" : 
{
"name" : "Donald Duck"
}
}

$.ajax({
type: "GET",
data: data,
cache: false,
dataType: "json",
success: function(json){
alert( json.member.name );
}
});

my problem is that the json.member.name is undefined??? why? how do I access it or what am I doing wrong?
if I use json.mybutt I get what I expect.. why does the json.member.name not work?

anyone... (been working 8 hours on this problem!)

regards,
Peter


--
Power Tumbling - http://www.powertumbling.dk
OSG-Help - http://osghelp.com

No comments: