Skip Navigation LinksHome > Categories > Code from a Category

How to use ajax in Zend Framework.



User Name: serfcompany
Name: Serf
Contact Me: www.datawebcoder.com
Home Page: www.datawebcoder.com
php,mysql,javascript,html,css. Preferable working with Zend Framework. Good know javascript. I worked with various, javascript frameworks such as(jquery, YUI3, extjs, sencha touch). I am very resp... [More]
Viewed Times: 127
Add Date: 01/17/2012
An article will show you how simple it is to use ajax in Zend Framework.
I am going to show you a simple way of using ajax in Zend Framework.

In this tutorial I will send data and get data without overloading page. At first you need to create a controller indexController or another controller which i created in previous articles to display main view, see in this article Zend Framework Quick Start.

Suppose we have indexController which calls index.phtml from folder application/views/scripts/index/index.phtml. Example of indexController: By default indexAction() links to the index/index.phtml
index.phtml this is the end point to display view data. example :
In view index.phtml i have created one text field and submit button which call javascript code when clicked.
My javascript ajax request tries to send data to the index/ajax Action .
but index/ajax still not exist yet. Let's create it. We should open an our main indexController and we have to add index/ajax action after the index/index Action . For example:
That's all. If you make all as I've described, you'll understand how ajax works in Zend Framework.

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Details**:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
 
    
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.