I need to do export file in my side, i have to to use the code below but is doesn’t trigger the controller. Any problem with the code? can anyone give me some advice?
I think you’ll have to pass an array to createUrl like CController:createUrl(array(‘sell/loadGame’)) to make this work. Use Firebug or something like that to see the ajax requests that are made.
EDIT: I was wrong, sorry. createUrl doens’t take an route array.
<div onclick="<?php echo CHtml::ajax(array(
'id'=>'country_list',
'type'=>'POST',
'url'=>array('sell/loadGame'),
'data'=>'test',
'success'=>'function(data) {}'));?>">Hallo
I am a Test</div>
You have to echo CHtml::ajax,
You have to get rid of the semicolon in your success function and
Set ‘data’
Interesting note: If you don’t set ‘data’ it will automatically be set by Yii with ‘data’:jQuery(this).parents(" form").serialize()});"="" causing a Javascript parsing error. This seems to be a bug
When using CHtml::tag it works even without setting data. This is interesting. But using CHtml::tag is more “Yii’ish” anyway, so you should use this code: