Home > Backend Development > PHP Tutorial > !yii里如何实现使用Jquery Ajax传值到控制器action方法里

!yii里如何实现使用Jquery Ajax传值到控制器action方法里

WBOY
Release: 2016-06-13 12:31:55
Original
903 people have browsed it

求助!yii里怎么实现使用Jquery Ajax传值到控制器action方法里

纠结一下午了,求高手相助,刚接触yii,这有什么问题吗
$.ajax({
type:'post',
url:"/www/index.php?r=home/CkUser",//这个地址应该怎么写

data:{"name":val},

success:function(msg){
alert("正确");
$("#nameinfo").html(msg);

},

}

);

我想传值到actionCkUser()里
class HomeController extends Controller{
public function actionCkUser(){
//todo

$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='用户已存在';
     }
    else
     {
$result='ok';
 }
return $result;
}
$this->render('CkUser',array(
'model'=>$model));
}

}

yii Jquery?Ajax
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template