JQuery Ajax returned blank data
- by kwokwai
Hi all,
I am learning how to use JQuery to help check data availability.
I have written a function in a Controller for checking data input, and the URL is like this:
http://www.mywebsite.com/controllers/action/avariable
but the returned data was blank.
<Script language="javascript">
$(document).ready(function(){
$(document).change(function(){
var usr = $("#data\\[User\\]\\[name\\]").val();
$.post{"http://www.mywebsite.com/controllers/action/",
usr,
function(msg){alert(msg);}
}
});
});
</Script>
<div id="username">
<input type=text name="data[User][name]" id="data[User][name]">
</div>
Here is the code of the Action:
function action($data=null){
$this->autoRender = false;
$result2=$this->__avail($udata);
if($result2==1)
{return "OK";}
else
{return "NOT";}
}