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
-
Use ZendX_JQuery. They have helper called ajax_link, with which you can use make ajax call directly from a link.
-
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.
-
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.
🙂