a53*_*416 -1 javascript ajax jquery .post
这是要返回的对象.
Object:
contributors_enabled: false
created_at: "Sat Apr 18 02:20:51 +0000 2009"
...
status: Object
...
verified: false
Run Code Online (Sandbox Code Playgroud)
如您所见,有2个对象.父级,然后是名为"status"的对象.
在javascript中,如何访问"status"对象.
我试过object.status返回null.
真实代码:
function get_data( $id ) {
global $tmhOAuth;
$code = $tmhOAuth->request( 'POST', $tmhOAuth->url('1/users/lookup.json', ''), array( 'user_id' => $id ) );
if ( $code == 200 ) {
$data = json_decode($tmhOAuth->response['response'], true);
return $data;
} else {
outputError($tmhOAuth);
}
}
if ( !empty( $_POST ) && !is_null( $_POST ) ) {
extract( $_POST ); //imports $id;
$data = get_data($id);
exit(json_encode($data));
}
$.post(
'/twitauth/app.php',
data,
function( response ) {
console.log( response );
},
'json'
);
Run Code Online (Sandbox Code Playgroud)
您需要发布实际代码,因为这两者中的任何一个都应该有效:
object.status
object["status"]
Run Code Online (Sandbox Code Playgroud)
如果这些不起作用,那么您已经以某种方式错误地定义了对象,或者对象内的对象是私有的.