Q:

Using JSON, passing variable from php to javascript

I wonder why is it not working?  
check_login.php
<? php
session_start();
$data = array("username" => "true");
echo json_encode($data);
? >

my js file
var linkName;
$.ajax({
    type: "POST",
    url: "check_login.php",
    dataType: "json",
    success: function(json){
    if(json.username ! = "true")
    {
      //do something
    }
    }
});

I am trying to get the username after checking whether or not the user has signed in yet in the php file, something like passing a session variable.  But currently passing a string seems to already have a problem.  Any know what I did wrong here? 
Still not working the code above.  Anyone want to help me out here? 

A:

You have an error in your PHP code.  The square bracket ] is not needed in line 3. 
And, of course you should use echo json_encode($data); 

