JQuery Ajax returned blank data
Posted
by kwokwai
on Stack Overflow
See other posts from Stack Overflow
or by kwokwai
Published on 2010-05-30T18:35:02Z
Indexed on
2010/05/30
18:42 UTC
Read the original article
Hit count: 202
jQuery
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";}
}
© Stack Overflow or respective owner