Making JSON Objects from Zend_Controllers (Using JQuery)

February 18th, 2009

I 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.

 

16 Responses to “Making JSON Objects from Zend_Controllers (Using JQuery)”

  1. Nexik says:

    great tutorial about ajax in zf:) time length is perfect.

  2. Jonathan says:

    I agree, the amount of time is fine, and I really appreciate your time and effort.

  3. Bob Hanson says:

    You time frame is great..no worries. Again thank you so much for taking the time to publish these. Youre a god send..

  4. Jim says:

    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

  5. zend dev says:

    a great contribution n good work
    thanks buddy

  6. Sven says:

    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. :)

  7. jon says:

    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!

  8. Hari K T says:

    Great tutorial . No need to break it .

  9. Christian says:

    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

  10. beregu says:

    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”;
    }

  11. wouldn’t you want to do

    return $articles->fetchAll()->toArray();

    instead of return $articles?

  12. fmf says:

    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.

  13. patrick says:

    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

  14. jon says:

    Hi patrick,
    <? is the equivalent of <?php
    and <?= is the equivalent of <?php echo

    hope that helps,
    -
    Jon

  15. Maciej says:

    After two days, I’ve found your video…
    THANK YOU.

  16. Thomas says:

    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

Leave a Reply

Desktop RSS feed iPhone + iPod