开发者

PHP to JQUERY - Accessing JSON Elements

开发者 https://www.devze.com 2023-03-29 10:04 出处:网络
I\'m sending the following from PHP to JSON print json_encode(array(\'success\' => TRUE, \'status\' => array(\'username\' => \'valid\', \'password\' => \'valid\', \'token\' => $tokenh

I'm sending the following from PHP to JSON

 print json_encode(array('success' => TRUE, 'status' => array('username' => 'valid', 'password' => 'valid', 'token' => $tokenhash)));

I can access success in JQUERY like this for example:

        function (data) {
            alert(data.success);

How can I access token? I tried alert(data.开发者_如何学编程success.token); Note: just using alert to see if I can hook into the required value.

Is there a syntax similar to data.success that I can use for token?

thx


Isn't it data.status.token that you are looking for ?


data.success is just grabbing the success key from your array. Looks like you want data.status.token.

0

精彩评论

暂无评论...
验证码 换一张
取 消