Using CHtml::ajax() with onclick attribute

Anyone know why the following piece of code gives a syntax error?




<div id="locationsBtn" class="menubutton" onclick="<?php echo CHtml::ajax(array(

                                'update'=>'#mainarea',

                                'type'=>'POST',

                                'url'=>array('location/index'),

                                'data'=>array('clientID'=>$client->clientID)

                        ));

                ?>">

                </div>



Thanks in advance.

plz try in these Way

<div id="locationsBtn" class="menubutton" onclick=\"<?php echo CHtml::ajax(array(

                        	'update'=&gt;'#mainarea',


                        	'type'=&gt;'POST',


                        	'url'=&gt;array('location/index'),


                        	'data'=&gt;array('clientID'=&gt;&#036;client-&gt;clientID)


                	));


        	?&gt;&#092;&quot;&gt;

Thanks for the reply, but that just gave amn illegal character error. Anyone else have a solution?

why don’t u copy and paste the exact message for the syntax error?

is it a PHP error or javascript error?

Thanks for the reply.

The error just said syntax error in the javascript that CHtml::ajax creates. I’ve scrapped using the onclick event and wrote my own jQuery function, which seems to work.

user CHtml::tag for div

<?php echo CHtml::tag(‘div’,array(

'onClick'=&gt;CHtml::ajax(array(


  


    'type'=&gt;'POST',


    'url'=&gt;array('contoller/action'),

// ‘success’=>‘function(data) {}’

  'update'=&gt;'#main',


)


    ),


  'class'=&gt;'box',//html option


  ),'',true


);

?>