Home > Backend Development > PHP Tutorial > ,Jquery ajax在yii里的url有关问题,

,Jquery ajax在yii里的url有关问题,

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

求助,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,
));
}

yii Jquery?ajax url
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