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(








Thanks in advance.

plz try in these Way

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







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(





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




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