title: php ajax msql jquery zend framework
body: <p>I'm using the Zend framework (php) and MySQL. My table named fruit has 2 columns. Name and Origin. I have a dropdown list for Name and based on whichever value the user selects, the 2nd dropdown for Origin would be populated after quering the database.</p>
  
  <p><strong>The Model</strong></p>
  
  <pre><code>&lt;?php
      class Application_Model_fruit extends Zend_Db_Table_Abstract
      {
          public function getname($origin)
          {
              $db = $this-&gt;getDefaultAdapter();
              $auth = Zend_Auth::getInstance();
              $select = "SELECT Name FROM fruit where origin = $origin";
              $stmt = $db-&gt;query($select);
              $result = $stmt-&gt;fetchAll();
              return $result;
          }
      }
  ?&gt;
  </code></pre>
  
  <p><strong>The Controller</strong></p>
  
  <pre><code>&lt;?php
      class fruitController extends Zend_Controller_Action
      {
          private $_db;
          private $info;
  
          public function init()
          {
              $this-&gt;_db = Zend_Registry::get('db');
              $this-&gt;info = new Application_Model_fruit();
          }
  
          public function nameAction()
          {
              $origin=$this-&gt;getRequest()-&gt;getParam('Origin');
              echo $data = $this-&gt;info-&gt;getname($origin);
          }
      }
  ?&gt;
  </code></pre>
  
  <p><strong>The .phtml</strong></p>
  
  <pre><code>&lt;div&gt;
      Name:
      &lt;select id="name"&gt;
          &lt;option value="1"&gt;Apple&lt;/option&gt;
          &lt;option value="1"&gt;Orange&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  
  
  &lt;div&gt;
      Origin:
      &lt;select id="origin"&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>The Ajax/Jquery</strong></p>
  
  <pre><code>&lt;script language="Javascript"&gt;
      $(document).ready(function(){
          $("#name").change(function(){
  
              $.ajax({
                  type:"POST",
                  url: "&lt;?php echo SITE_URL;?&gt;fruit/name",
                  data:"Name="+$("#name").val(),
  
                  success:function(ret){
                      $("#origin").val(ret);
                  }
              }); 
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Could somebody please help me? I don't get any output in the 2nd dropdown list.</p>