문제

I just started learning AJAX and Yiiframework. What are the steps to create 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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top