Heim >Backend-Entwicklung >PHP-Tutorial > ,Jquery ajax在yii里的url有关问题,
求助,Jquery ajax在yii里的url问题,急
我想传值到后台控制器方法里,但是怎么写url都不行
var data="name="+val;
//alert(data);error:function(){alert('错误');}
$.ajax({
type:'post',
url:"http://localhost/message/www/index.php?r=home/CkUser",
data:data,
success:function(msg){
alert('msg');
$("#nameinfo").html(msg);
},
}
下面是action方法:
public function actionCkUser(){
//$name = $_POST['name'];
$name=Yii::app()->request->getParam('name');
echo $name.'bb';
$model=new User;
if($name)
{
$model->username=$name;
$user = User::model() -> find("username = '{$this -> username}'");
$result='';
if($user)
{
$result='用户已存在';
echo '用户已存在';
}
else
{
$result='ok';
echo 'ok';
}
return $result;
}
Yii::app()->end();
$this->render('CkUser',array(
'model'=>$model,
));
}