How to pass some data to JQuery AJAX in CAKEPHP
<p>I am learning how to use JQuery to help check data availability.<br/>
To start with it, I wrote a few lines of codes using cakePHP.<br/></p>

<p>I have written a function in a Controller for checking data input, <br/>and the URL is like this:
<a href="http://www.mywebsite.com/controllers/action/avariable" rel="nofollow">http://www.mywebsite.com/controllers/action/avariable</a>
<br/>
I was trying to pass the value in a Input TextBox field using the JQuery Ajax to the URL above,<br/>but I don't know why it is not working in passing a variable to the Controller's action. <br/>Could you help me out please?<br/></p>

<pre><code>&lt;Script language="javascript"&gt;
//&lt;!--
$(document).ready(function(){  
$(document).change(function() { 
var usr = $("#data\\[User\\]\\[name\\]").val();
if(usr.length &gt;= 3){ 
$("#username").append('&lt;span&gt;&lt;img align="absmiddle" src="loader.gif" /&gt;Checking&lt;/span&gt;');

$.ajax({ 
type: "POST",
url: "http://www.mywebsite.com/controllers/action/",
data: usr,
success: function(msg){

     if(msg == 'OK')
     {
     $("#username").append('&lt;span&gt;&lt;img align="absmiddle" src="accepted.png"/&gt;&lt;/span&gt;');
      }
     else
     {
     $("#username").append('&lt;span&gt;'+msg+'&lt;/span&gt;');
     }
      } 
     });
      }
else
{
$("#username").append('&lt;span&gt;The username should have at least 3 characters.&lt;/span&gt;');
}

});
}); 
//--&gt;
&lt;/Script&gt;

&lt;form name="adduser" id="adduser" method="post" action="/controllers/action2"&gt;
&lt;table border=0 width="100%"&gt;
&lt;tr&gt;
 &lt;td&gt;Username&lt;/td&gt;
 &lt;td&gt;       
        &lt;div id="username"&gt;
 &lt;input type=text name="data[User][name]" id="data[User][name]"&gt;
 &lt;/div&gt;       
        &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;
 &lt;input type="submit" value="Send"&gt;
 &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p><br/>
Here is the code of the Action:</p>

<pre><code> function action($uname=null){
                 $result2=$this-&gt;__avail($uname);           
                  if($result2==1)
                   {return "OK";}
                   else
                   {return "NOT";}           
            }
</code></pre>
