开发者

What are the steps to create AJAX login in yiiframework?

I just started learning AJAX and Yiiframework. What are the steps to crea开发者_运维问答te AJAX login form in Yii?

Thank you.


Try the following in your view, where the login button is

<?php echo CHtml::ajaxButton('Add Course', array('student_Courses/Create'),array(
        'type'=>'POST',
        'update'=>'#resultStudentCourse',
        'beforeSend' => 'function(){
            $("#resultStudentCourse").addClass("loading");
        }',
        'complete' => 'function(){
            $("#resultStudentCourse").removeClass("loading");
            }',

)); ?>

#resultStudentCourse is the ID of the DIV where you need to load in your message, EG. Successfully logged-in

Then in your controller the create method have something like this

if(Yii::app()->request->isAjaxRequest){
$this->renderPatial('create',array('model'=>$model));
}

Hope this helps


    if(Yii::app()->request->isAjaxRequest){
$this->renderPatial('create',array('model'=>$model));
}

For the sake of real clarity (as not too many folks are using this framework quite yet) the above should be

$this->renderPartial
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜