For some reason this does not work, and I cannot find a way to make it work!
on my controller named "ExplicacaoController" I have this:
public function accessRules() ... 'actions'=>array('index','view', 'test', 'ajaxrequest'), ... public function actionAjaxRequest() { $val1 = $_POST['val1']; $val2 = $_POST['val2']; echo "something"; Yii::app()->end(); }
In my opinion, I:
<script type="text/javascript"> ... $.ajax({ type: "POST", url: "<? echo Yii::app()->createUrl('explicacaoController/ajaxRequest'); ?>", data: {val1:1,val2:2}, success: function(msg){ alert("Sucess") }, error: function(xhr){ alert("failure"+xhr.readyState+this.url) } }); ...
What happens is that I always get this error:
failure4<? echo Yii::app()->createUrl('explicacaoController/ajaxRequest'); ?>
I really need help with this
source share