jquery - access json data from php
Posted
by Cinaird
on Stack Overflow
See other posts from Stack Overflow
or by Cinaird
Published on 2010-04-12T13:21:21Z
Indexed on
2010/04/12
13:23 UTC
Read the original article
Hit count: 374
I have a problem accessing JSON data. I'm new to JSON an jquery so there is probably a easy solution to it and i would be glad to find out.
My jQuery:
$.post(
"currentPage.php",
{
'currentPage': 1
},
function(data){
$("body").append(data);
}
);
currentPage.php:
$returnArray['left'] = 'test_left';
$returnArray['right'] = 'test_right';
$returnArray['numLeft'][] = 1;
$returnArray['numRight'][] = 2;
$returnArray['numRight'][] = 3;
print json_encode($returnArray);
i tried to access the data like this: data.left data['left']
but it returns blank, how is the best way to access the data?
© Stack Overflow or respective owner