Question

I just started learning AJAX and Yiiframework. What are the steps to create AJAX login form in Yii?

Thank you.

Was it helpful?

Solution

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

OTHER TIPS

    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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top