0
Welcome Guest! Login
0 items Join Now

ROCKETTHEME IS CLOSING ON JUNE 30, 2025. As a thank-you to our community, enjoy 50% off all themes with the promo code THANKYOU before we shut down. Read our Farewell Blog Post for more details.

How to make an ajax call?

  • How to make an ajax call?

    Posted 12 years 11 months ago
    • Hi,
      I am trying to use your ajax model implementation as it is described in the ganrty-framework page.
      Looking in to the code I found that the gantry-ajax.php and gantry-ajax-admin.php has been converted to the ajax functions in the corresponding controllers.
      I have created a php file and store it in the rt-clarion/admin/ajax-models directory.
      The main problem is that I can not figure out how to call it.
      I tried the following:
      my.domain.com/administrator/index.php ?option=com_gantry&task=ajax&model=myphpfile
      But it failed.
      Any help or ideas on how to call the my model, it would be appreciated.
  • Re: How to make an ajax call?

    Posted 12 years 11 months ago
    • calling the model example.php with index.php?option=com_gantry&task=ajax&model=example
      returns error
      Call to a member function get() on a non-object in /var/www/libraries/gantry/gantry.php on line 245
      any ideas?
  • Re: How to make an ajax call?

    Posted 12 years 11 months ago
    • I found how to call the ajax model, but I think there is a bug in the code.
      I know that rockettheme has implemented a new type of Ajax using the rokcommon, which is more complex. But since it features that in their templates and in the gantry framework, it would be nice to let us know how to use it.
      I was expecting an answer to my simple, i thought, question.

      Anyway, in order to make the ajax models to work, you need to call them like this:
      index.php?option=com_gantry&task=ajax&model=example&format=xml&template=<your template name>
    • Last Edit: 12 years 11 months ago by George Bouleros.
  • Re: How to make an ajax call?

    Posted 12 years 11 months ago
    • In order to avoid the passing the template name in the ajax call, I changed ajax function in the com_gantry controller from...
             // get current template
              $template = &JFactory::getApplication()->getTemplate();
              // load and inititialize gantry class
              $gantry_path = JPATH_SITE . '/libraries/gantry/gantry.php';
              if (file_exists($gantry_path))
              {
                  require_once($gantry_path);
              }
              else
              {
                  echo "error " . JText::_('Unable to find Gantry library.  Please make sure you have it installed.');
                  die;
              }
       
              $model = $gantry->getAjaxModel(JRequest::getString('model'),false);
              if ($model === false) die();
              include_once($model);
       

      to...
             // get current template
              $template = &JFactory::getApplication()->getTemplate();
       
              JRequest::setVar("template", $template);
       
              // load and inititialize gantry class
              $gantry_path = JPATH_SITE . '/libraries/gantry/gantry.php';
              if (file_exists($gantry_path))
              {
                  require_once($gantry_path);
              }
              else
              {
                  echo "error " . JText::_('Unable to find Gantry library.  Please make sure you have it installed.');
                  die;
              }
       
              $model = $gantry->getAjaxModel(JRequest::getString('model'),false);
              if ($model === false) die();
              include_once($model);
       

      thus saved the problem of hardcoding in my code the template name

Time to create page: 0.074 seconds