Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3960708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:53:10+00:00 2026-05-20T02:53:10+00:00

I have a application built using Zend Framework. I have decided to go with

  • 0

I have a application built using Zend Framework. I have decided to go with JQuery instead of Dojo. I do use the ZendX helpers for stuff like ajaxLinks and dialogContainers. I want to try and make the GUI as AJAX driven as possible. But I struggle with deciding on what I feel is the best approach.
Most of the time it’s a matter of loading a “page” into a dialogContainer instead of reloading the entire page. So that you for instance get a dialog containing a form for changing some user data or something similar.

At first I returned the entire page but if it was requested using an AJAX request it used a different layout template to avoid all unenecerry javascript inclusions etc. This enabled my to build one version of a page that would basicly be browsable like normal AND via AJAX. But I haven’t conviced myself that I like this. Looking at Zend Server GUI they seem to do this though and not return json encoded data and building the page from that.

What would be the best approach for this and how should I handle javascript that is specific to the retrived page? I now have all the page specific javascript in the phtml file of that page.

Another thing I’m concerned about is how to keep track of the resources created when opening a lot of dialog containers and populating them via ajax. Say we open one dialog and in that we get a list of items. If we click one yet another modal dialog container popsup for that specific item and is populated via ajax. But if the main page is never reloaded I can see this becoming hard to handle.

Feels like I can’t be the first one to wanna do an ajax driven UI so please point me in the right direction before I paint myself into a corner. 😉

Update: I basicly tried all kinds of tutorials I could find on the context subject as well as the documentation at Zend. I think I must have missed to enable some undocumented feature or something. Since it didn’t work I deleted the code, but trying to find the examples I looked at before I tried stuff like the bellow code.

$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('list', 'html')
            ->addActionContext('modify', 'html')
            ->initContext();

And I tried something like the following

$this->_helper->contextSwitch()
     ->setContext('html', array(
                 'suffix'    => 'html',
                 'headers'   => array('Content-Type' => 'text/html; Charset=UTF-8'),
)
         )
     ->addActionContext('index', array('html','xml', 'json'))
     ->setAutoJsonSerialization(true)
     ->initContext(); 

I tried adding other ActionContexts etc but no matter what all of them just ended up rendering the normal .phtml file all the time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:53:10+00:00Added an answer on May 20, 2026 at 2:53 am

    Here’s what I learned when I was making my ZF/Ajax app.

    For HTML Data:

    You can use ActiionContext action helper (ZF Reference). You can add an AJAX context to your actions. I use this in controller’s init() function.

    $ajaxContext = $this->_helper->getHelper('AjaxContext');
    $ajaxContext->addActionContext('myaction', 'html')->initContext('html');
    

    What this does is, when calling myactionAction(), it will check if the request is made through an AJAX call. If it is, it disables the layout, and renders “myaction.ajax.phtml” rather than “myaction.phtml” as it would if it wasn’t an AJAX call. This way, you can get a clean HTML output from an action without anything extra, you don’t have to write a Request-Type checking code in each action. I found it generally easy work with.

    If the content you are loading carries additional javascript with it, don’t forget to add it to your view and echo it as well.

    $this->headScript()->appendFile("/js/list.js");
    echo $this->headScript(); 
    

    That JavaScript then executes as it normally would.

    For JSON Data

    JSON Action Helper is very quick and easy to use in an action to return JSON data.

    $r = "Success"; 
    $this->_helper->json($r);
    

    This also returns pure JSON and nothing else.

    I guess a little more specific question would help you get better answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I make a distributed embedded application that will make use of several micro-controllers. The
I have a snippet to create a 'Like' button for our news site: <iframe
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I have found this example on StackOverflow: var people = new List<Person> { new
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
Let say I have the following desire, to simplify the IConvertible's to allow me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.