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 4585646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:31:30+00:00 2026-05-21T21:31:30+00:00

i want manage result of ajax in phtml file, this is my view code

  • 0

i want manage result of ajax in phtml file, this is my view code that ajax link is there:

<div id="container"></div><?php echo $this->ajaxLink("Link Name",
                      $this->baseUrl() ."/admin/index/first/format/json",
                      array('update' => '#container',
                            'method' => 'POST')); ?>

this is first action code :

public function firstAction()
{
    if($this->_request->isPost()) {         
        // pretend this is a sophisticated database query
        $data = array('red','green','blue','yellow');
        $jsonData = Zend_Json::encode($data);
        $this->view->data = $jsonData;
    }
}

this is first.phtml code :

<ul><?php foreach ($this->data as $color) : ?><li><?= $color ?></li><?php endforeach; ?></ul>

but there is a prob! result of ajax show like this:

{“data”:”[\”red\”,\”green\”,\”blue\”,\”yellow\”]”}

and it don`t use of first.phtml file!

is there any way fo solve this prob?

  • 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-21T21:31:31+00:00Added an answer on May 21, 2026 at 9:31 pm

    answer : i found the answer with Marcin help 😉

    public function firstAction()
    {
        if($this->_request->isPost()) {         
            // pretend this is a sophisticated database query
            $data = array('red','green','blue','yellow');
            Zend_Layout::getMvcInstance()->disableLayout(); 
            //$jsonData = Zend_Json::encode($data);
            $this->view->data = $data;
        }
    }
    

    and i delete every json parameter form ajaxlink and init method

    $ajaxContext = $this->_helper->getHelper('AjaxContext');
        $ajaxContext->addActionContext('first', 'html')
                    //->addActionContext('format', 'json')
                    ->initContext();
    

    every thing is now correct 🙂

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

Sidebar

Related Questions

I want to ask pro developers out there that how they manage a big
I want to write a unit test for a Django manage.py command that does
What I want to achieve is Here is my code which didn't manage to
I want to fetch the content of an text file and I have manage
How can i manage this query. I want to have only one person in
I want to program a Terminal emulator in php and jquery or ajax. My
I want to create a class in c++. This class must manage with a
I have a project that originally did not use ajax. Now I want to
I want to manage permissions and access to a SQL Server database server on
For my iPhone app, I want to manage values either in NSMutableDictionary or NSMutableAarray

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.