开发者

PHP to JQUERY - Accessing JSON Elements

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜