Calling a method in the Model while making Ajax call - Joomla! Forum - community, help and support


hi all,

currently working on ajax call inside mvc architecture of joomla.

1. make ajax call, , control passes on controller specify model needs used.

2. method in particular model called upon.

however @ instance getting following error,
fatal error: call member function getcities() on non-object in c:\xampp\htdocs\joomla25\components\com_hello\controller.php on line 29

code: select all

controller.php
 function listcities()
    {
         
          $model = $this->getmodel('all');
          $lists = array();
          $state_name = jrequest::getvar('state_name');
          $cities = $model->getcities($state_name);    // getting fatal error @ point.
          echo "<br>the cities listing state: ".$state_name;
          echo "<table><tr>";
          echo "<td>"."city name"."</td></tr>";
          for($i=0, $n=count($cities); $i < $n; $i++)
          {
                    $city = $cities[$i];
                    echo "<tr>";
                    echo "<td>";
                    echo $city->city;
                    echo "</td>";
                    echo "</tr>";
          }
          echo "</table>";
   }

code: select all


all.php ( model)
   function getcities($state_name)
   {   
            
         $query ="select distinct city location_master state='".$state_name."'";
         $this->_hellos = $this->_getlist($query,0,0);
      

      return $this->_hellos;
   }


i pretty new php/joomla, can please tell me making mistake.






Comments