Making JSON Objects from Zend_Controllers (Using JQuery)
February 18th, 2009I started this video thinking it would be short and it ended up close to 30 minutes. If you find these videos too long, please let me know and I’ll break them up.
In my own defense, this video covers a lot of ground. I introduce JQuery and immediately put it to work for sending and receiving JSON requests to our Zend_Controller. The JSON is automatically generated from a set of PHP classes in a PHP array, thanks to Zend_Json.
also, download the project file for this episode.

great tutorial about ajax in zf:) time length is perfect.
I agree, the amount of time is fine, and I really appreciate your time and effort.
You time frame is great..no worries. Again thank you so much for taking the time to publish these. Youre a god send..
the longer the better! I’m actually sending my developers to this site to get more ZF training for our apps.
keep it goin! thanks
a great contribution n good work
thanks buddy
Is there a reason for, doing it with jQuery and not doing it with Dojo?
Can you please make a Tutorial of doing this with Dojo?
May be, to see the difference?
Thanx for your very good work.
Hey Sven,
I’m sure I’ll get around to Dojo, however I usually cover technologies I’m familiar with and use regularly. Dojo hasn’t been a part of my development practice so I’d have to study up on it first!
Great tutorial . No need to break it .
Hi John,
thanxs for this tutorial.
Its great but i have some issue with it.
Cant get the AsyncController to work.
Is this also working with zend 1.8 and above.
Christian
Thanks for your great tutorial.
It’s still working properly with ZF 1.9.4.
As John’s tutorial, AsyncController->generateItems() generates a json encoding ready array. I just wonder how I can make json encoding ready array from typical db table object?
I just replaced all generateItems() code with the following, but it’s not working:
==========
private function generateItems()
{
$articles = new BEREGU_ArticlesDbTable();
$articles->fetchAll()->toArray();
return $articles;
}
==========
BEREGU_ArticlesDbTable()
==========
class BEREGU_ArticlesDbTable extends Zend_Db_Table_Abstract
{
protected $_name = “articles”;
}
wouldn’t you want to do
return $articles->fetchAll()->toArray();
instead of return $articles?
Thanks for all you good tutorials !
I like how you present small, essential examples and still drop in some notes how one would act in more real-world like situation.
I appreciate the tutorial.. Curious what does the <? .. and <?= do ..?
I've always used <?php and for some reason this did not work on my version of the Zend framework.
I assume it is an appreviation, but was not sure.
Great tutorial
Hi patrick,
<? is the equivalent of <?php
and <?= is the equivalent of <?php echo
hope that helps,
-
Jon
After two days, I’ve found your video…
THANK YOU.
Thanks, man!
Even though i am missing the Database support you are giving perfect advices.
I didnt know about the return false to remove the anchor tags.
THX