Ajax Dropdown Unwanted Symbols And Arabic

Hi all

I’m using a ajax drop down, one drop down influences the other via ajax call. Everything works but I have some annoying issues.

Here’s my code

Controller


public function actionShowcity(){

	

	$dropShows = "<option value='null'>Select Showroom </option>";

 

            // return data (JSON formatted)

            echo CJSON::encode(array(

              'dropShows'=>$dropShows,

             

            ));

if( isset($_POST['city_id'])){




    $data=Showroom::model()->findAll('Title=:Title', 

                  array(':Title'=>(String) $_POST['city_id']));

 

    

				   $data=CHtml::listData($data,'ID','Name');

    foreach($data as $value=>$name)

    {

        echo CHtml::tag('option',

                   array('value'=>$value),CHtml::encode($name),true);

				   

				   

    }

}


   

}




public function actionGotoShow(){

     $data=Showroom::model()->findAll('Name=:Name', 

     array(':Name'=>(String) $_POST['myID']));

	 $this->redirect(array('/showroom'.'/'.$_POST['myID']));


}

index




<?= CHtml::form(); ?>

	<?php

	$options["options"] = array("style" => "color:red;");

	echo CHtml::dropDownList('city_id','', CHtml::listData(Showroom::model()->findAll(),'Title', 'Title'),

array(

"style" => "color:#989898; width:200px; height:30px;",

'empty'=>'Choose a City',

'ajax' => array(

'type'=>'POST', //request type


'url'=>CController::createUrl('showroom/showcity'), //url to call.

'update'=>'#myID', //selector to update

))); 

 

echo CHtml::dropDownList('myID','', array(), array( 

"style" => "color:#989898; width:200px; height:30px;",

'empty'=>'Pick City first',

	'submit'=> '/index.php/showroom/GotoShow'));

?>	

<?= CHtml::endForm(); ?>



So I choose my first drop down, and the message select showroom comes out as

select Showroom<\/option>"} exactly like that with all the symbols.

if I remove the closing option I get select Showroom"} (the comma and curly bracket included)

Also I have 2 version of the site one is arabic so when I do this


$dropShows = "<option value='null'>يبسب";

 

            // return data (JSON formatted)

            echo CJSON::encode(array(

              'dropShows'=>$dropShows,

             

            ));

The result is {" u064a\aU0628\u0633\

Anyone know how I can 1) get rid off the symbols and 2) get the Arabic letters to display?

EDIT: There’s a function that converts to UTF8 but it’s not working, the drop down stops working




	$dropShows = "<option value='null'>يبسب";

 $dropShows = CJSON::unicodeToUTF8( $dropShows );

            // return data (JSON formatted)

            echo CJSON::encode(array(

              'dropShows'=>$dropShows,

             

            ));

Thanks

please check around json::encode function.