2

I want to make a lightweight ajax call in Joomla ( all I need is basically a php script that makes a curl call). Currently, we're doing this in components controller tasks (com_home, com_widgit, etc).

This is causing a lot of unneeded overhead by loading Joomla. Performance testing shows that a plain php script with a curl call is order of magnitudes faster than using the joomla controller.

I've looked into the com_ajax but from what I can tell its not what I'm looking for since I'm the component developer: http://docs.joomla.org/Using_Joomla_Ajax_Interface

If you are a component developer, you do not need to use com_ajax to implement Ajax functionality in it. You can do so directly in your component.

I also have access to the server and can make ajax calls outside of Joomla, but since that seems like a hack I'd rather use Joomla, if possible.

Is there a way to make a lightweight ajax call in joomla?

3

1 Answer 1

1

Thinking in the lightweightest way to call your component, since you are executing inside Joomla, you have to wait until the CMS is initialized. (If not, thn you are looking for an external script)

  • Following all the available core events, you can create a plugin to answer the call and stop the rest of the execution. For instance, onAfterInitialise
  • You can also, execute in any of the following events, e.g. onAfterRoute http://docs.joomla.org/Plugin/Events
  • As you are the component developer, you can install a create a plugin and install a plgAjaxYxxxx
  • If you want to keep it inside the component, and avoid plugins, then you can return the response inside the main component php script, in the internal dispatcher, or as a task in a controller.

In my experience, I prefer to implement it as a task in the controller. In this way, all business reponsabilities are in a single place. Beyond the extra load, it is easier to mantain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.