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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:33:45+00:00 2026-06-01T09:33:45+00:00

I Have two problem in this Case : I want to pass a JSON

  • 0

I Have two problem in this Case :
I want to pass a JSON object that i created in Zend Controller

public function exampleAction() {
    $answers = array();
    for($i = 0 ; $i < 3 ; $i++)
     {
                $answer = new Answer();
                $answer->answer_id = 5 ; // for example
                $answer->thanked = 'true';// for example
                $answers[] = $answer;
     }

    echo Zend_Json_Encoder::encode($answers);
}

the Jquery Post function is :

 $.post(
      "/memberactions/getthanks/",
      {values:values},
        function(res){   
           alert(123);     
        } 
      , 'json')

First Question :
why the return response is HTML ? the response must be in JSON ?

Second Question
the HTML response is like this

[{"__className":"Answer","thanked":"true","answer_id":"5"}]

How can I make the response like this :

 - answer 
     thanked : true
     answer_id : 5

as a JSON Object without the __className:”Answer” (does it hurt to have the class name in the response) ?

  • 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-06-01T09:33:46+00:00Added an answer on June 1, 2026 at 9:33 am
    1. Have you disabled layout, viewRenderer etc.? Also, you should send appropriate headers. You can do all this at once using the JSON action helper:

      $this->_helper->json($answers);

    2. You could provide a toArray() method in Answer, which would return an array of relevant properties and then use it in your action:

      $answers[] = $answer->toArray();

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

Sidebar

Related Questions

I have a problem with IE causing two errors: 1. Object doesn't support this
I have problem that I need to create timer but I want to pass
My problem is this: I have two threads, my UI thread, and a worker
So i'm having this problem. I have two tables (Oracle), one is called Destination
Can someone explain to me how I can fix this problem. I have two
I have had this problem w/ two seperate WYSWYG editors in my rails application
I have this little problem. My client wanted two distinct swf on a web
I have a two-step search problem. First I want to see if any matches
Similar question here but this is slightly different... I have two tables that I
i have a problem concerning a select query in MYSQL i have two different

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.