title: phalcon and jquery ajax
body: <p>I am using Phalcon PHP framework. First I have problem to get value of Tag::textField in jquery. I am interested in accessing a value of <code>Tag::textField</code> from jquery.
  Second question is how to call a controller's method using AJAX. I am trying to call method <code>posalji()</code> from my XML controller on a button click, and it's not warking. Here is my controller method I am trying to call:</p>
  
  <pre><code>public function posaljiAction()
  {
      $data = "Ja se zovem Nedim Omerbegovic";
      echo json_encode($data);
  }
  </code></pre>
  
  <p>And here is my view (pretraga.phtml):</p>
  
  <pre><code>&lt;?php
      use Phalcon\Tag;
  ?&gt;
  &lt;?php
      echo Phalcon\Tag::javascriptInclude("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false);
      echo Phalcon\Tag::javascriptInclude("javascript/jquery.js");
  ?&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              $("#dugme").click(function(){
                  $.ajax({
                      url: "&lt;?php echo $this-&gt;url-&gt;get("xml/posalji") ?&gt;",
                      type:'POST',
                      dataType: 'json',
                      success: function(data) {
                          alert(data);
                      }
                  });     
              });
          });
      &lt;/script&gt;
  
      &lt;h2&gt;Primjer penosa varijable iz controllera to view-a&lt;/h2&gt;
      &lt;?php echo Tag::form("xml/pretraga"); ?&gt;
      &lt;p&gt;
          &lt;label for="name"&gt;Naslov&lt;/label&gt;
          &lt;?php echo Tag::textField("naslov") ?&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;?php echo Tag::submitButton("prikazi") ?&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  
  
  &lt;form&gt;
      &lt;label for="text"&gt;Unesi:&lt;/label&gt;
      &lt;p&gt;
          &lt;input type="text" id="unos"/&gt;
      &lt;/p&gt;
      &lt;input type="submit" id="dugme" value="Prikazi"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>