cakephp 2.2 retrieve json data in controller
===

I'm trying to send JSON data from a web page using JQuery, like this:

    $.ajax({
        type: "post",		// Request method: post, get
        url: "http://localhost/ajax/login",
        data: '{username: "wiiNinja", password: "isAnub"}',
        dataType: "json",	// Expected response type
        contentType: "application/json",
        cache: false,
        success: function(response, status)
        {
            alert ("Success");
        },
        error: function(response, status)
        {
            alert('Error! response=' + response + " status=" + status);
        }
    });

In cake2.2, I have a controller named Ajax that has a method named "login", like this:

    public function login($id = null)
    {
        if ($this->RequestHandler->isAjax())
        {
            $this->layout = 'ajax'; // Or $this->RequestHandler->ajaxLayout, Only use for HTML
            $this->autoLayout = false;
            $this->autoRender = false;
    
            $response = array('success' => false);
    
            $data = $this->request->input(); // MY QUESTION IS WITH THIS LINE
            debug($data, $showHTML = false, $showFrom = true);
        }
        return;
    }

I just want to see if I'm passing in the correct data to the controller. If I use this line:

$data = $this->request->input();

I can see the debug printout: 

'{username: "wiiNinja", password: "isCool"}'

I read in the CakePHP manual 2.x, under "Accessing XML or JSON data", it suggests this call to decode the data:

       $data = $this->request->input('json_decode');

When I debug print $data, I get "null". What am I doing wrong? Is my data passed in from the Javascript incorrect? Or am I not calling the decode correctly?

Thanks for any suggestion.

