Thank you bcworkz, but it’s not working.
The object is too complex. I can’t apply that synthax for my case.
When I write that stuff :
obj.display_name
The alert display ‘undefined’.
I try some synthax which not working too:
obj.data.display_name
obj['data'].display_name
I reproduce a simple version of my coding context :
<?php
/* Template Name: Test1 */
get_header();
$user = new WP_user_query('include=1');
$final_user = $user->results;
?>
<div class="info"><?php echo json_encode($final_user); ?></div>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var usr = jQuery.parseJSON($('.info').html());
console.log(usr);
alert(usr.display_name);
});
</script>
<?php
get_footer();
?>