Ajax Filtering Problems With Checkbox When Empty

Hi

I’ve problem with ajax filtering results. When i check checkbox as checked everything works fine, but if i uncheck last checked it ajax starts loading but results are same when it was checked :( This only happens when user have clicked last checked checkbox as unchecked. Is there some solution for this? This is very urgent for my project! Hope you can help me! Thanks in advance.

Code:

Code in view:

JS-part

$(’.hairFilter’).click(function(){

hair = $('.hairFilter').serialize();


$.fn.yiiListView.update(


    'ajaxListView',


    {data: hair}


);

});

PHP-part

$listData = CHTml::listData(ProfileHair::model()->findAll(),'id','name');


$t_listData = array();


foreach($listData as $key => $item)


{


       $t_listData[$key]=Yii::t('profile',$item);


}


echo CHtml::label('<strong>'.Yii::t('profile','Hair').'</strong>','hair');


echo CHtml::checkBoxList('hair', (isset($_GET['hair'])) ? $_GET['hair'] : '', $listData,


       array(


        'class'=>'hairFilter',


        'style'=>'font-size: 10px',


        'checkAll'=>Yii::t('profile','All'),


        'return'=>true,


         $ajaxOptions = array(


    'type'=>'POST',


    'dataType'=>'json',


    'beforeSend' => 'function(){





        $("#ajaxListView").addClass("loading");


     


    }',


    'complete' => 'function(){


        $("#ajaxListView").removeClass("loading");


    }',


 ),


 )

);

Code in controller:

public function actionIndex(array $hair = array()){

  if( count( $hair ) > 0 ){


        $criteria->addInCondition( 'hair_id', $hair );


  }





  ...........





  $this->render( 'index', array( 'dataProvider' => $dataProvider ) );

Solved it already :) Thanks anyway!