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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:41:06+00:00 2026-05-20T03:41:06+00:00

In one of my actions in a controller, I’m using the json view helper

  • 0

In one of my actions in a controller, I’m using the json view helper to send back a response to an ajax request. On the client side I alert the data that is passed to the success callback function. It works fine as long as the response is a number or an array with default keys. Once I try to send an associative array, it alerts with [object Object].
Server code:

$childArray = array('key'=>'value');
$this->_helper->json($childArray);

javascript:

function displayChildren(data){
    alert(data);
}
...    
$.ajax({
        url: "/po/add", dataType: "json",
    data: {format: "json"}, success: displayChildren
});

I have no idea what am I doing wrong here, so any help would be appreciated…

  • 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-20T03:41:07+00:00Added an answer on May 20, 2026 at 3:41 am

    That’s expected. Associative arrays in Javascript are objects. Alert won’t iterative over the object’s properties and just outputs [object Object]. The key/value pairs you set on the PHP side are there and be accessed. try alert(data.key) and you should get value.

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

Sidebar

Related Questions

I have a request to one of my actions in a controller that expects
How can one best test a controller action which receives a file upload using
I'm trying to use F# for an ASP.NET MVC application. One my controller actions
I need one of my controller actions to return a list of names, on
In one of my controller actions, I'm generating some XML. One of the attributes
I currently have a .find method in one of my rails controller actions -
I'm having trouble writing a unit test for one of my controller actions. Here's
I have an ASP.NET MVC web app and in one of the controller actions
how can i render multiple different actions in one call to a speccific controller?
In django, can I have 2 controller actions with the same name, but one

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.