December 30, 2011

How to use ajax in zend framework?

Question by sarunathan

I tried a simple ajax aplication using jquery, where i had my php file in an separate folder in my root and it is working.

Is there any other way to use ajax in a zend framework?

Answer by Starx

There are some ways you can do it

  1. Use ZendX_JQuery. They have helper called ajax_link, with which you can use make ajax call directly from a link.

  2. Embed a js file, in your file and use ajax there. Use something like:

    $this -> headLink() -> appendScript(‘path/to/your/script’);

    You might have to import the JQuery file like this, if you have not enabled this, using the ZendX_JQuery helper.

  3. Directly feed script content like <script>...</script> like you would raw html

However, JQuery helper might take a bit to fully understand. If you are already familier with JQuery, and know how to use it properly. Go with option number 2.


Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!