title: ajax call controller in yii (javascript)
body: <p>For some reason this doesnt work and I can't find a way to make it work!</p>
  
  <p>on my controller named "ExplicacaoController" I have this:</p>
  
  <pre><code>public function accessRules()
  ...
  'actions'=&gt;array('index','view', 'test', 'ajaxrequest'),
  ...
  public function actionAjaxRequest()
      {
        $val1 = $_POST['val1'];
        $val2 = $_POST['val2'];
        echo "something";
  
        Yii::app()-&gt;end();
      }
  </code></pre>
  
  <p>On my view I have:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  ...
  $.ajax({
        type: "POST",
        url:    "&lt;? echo Yii::app()-&gt;createUrl('explicacaoController/ajaxRequest'); ?&gt;",
        data:  {val1:1,val2:2},
        success: function(msg){
             alert("Sucess")
            },
        error: function(xhr){
        alert("failure"+xhr.readyState+this.url)
  
        }
      });
  ...
  </code></pre>
  
  <p>What happens is that I allways get this error:</p>
  
  <pre><code>failure4&lt;? echo Yii::app()-&gt;createUrl('explicacaoController/ajaxRequest'); ?&gt;
  </code></pre>
  
  <p>I really need some help with this</p>