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

  • Home
  • SEARCH
  • 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 8416559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:47:38+00:00 2026-06-10T01:47:38+00:00

I have a problem when returning an array object and then display it to

  • 0

I have a problem when returning an array object and then display it to the user, please look at the demo code. A basic snippet but it has the same idea has been, I just can’t post the very long code here.

Class foobar{
   public function foo()
   {
     return array( 'bar' => 'value' );
   }
}

This php code was used by another class

Class foobar_fetcher{
   public function getFoo()
   {
     $fb = new foobar();
     $result = $fb->foo();
     return $result;
   }
}

foobar_fetcher is again called by a main executioner file( ajaxdispatcher.php ) – with a json header.

if( isset( $_POST['fetch'] ) ){
   $httpresponse = new stdClass();
   $fb_fetch = new foobar_fetcher();
   $httpresponse->data = $fb_fetch->getFoo();
}

echo json_encode( $httpresponse );

Finally this ajaxdispatcher was called by a jquery ajax.

$.ajax({
  url: 'ajaxdispatcher.php',
  type: 'post',
  data: {fetch:'fetch'},
  success: function( data ){
      if( data ) console.log( data );
  }
});

Now, the when I try to print out the data , it has no response from the server.
But when I change the return value of the foo() under foobar Class to an integer or string. Things will work fine.

  • 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-10T01:47:39+00:00Added an answer on June 10, 2026 at 1:47 am

    You should try to change you ajaxdispatcher to accept a GET request and navigate there from a browser to see what is returned.

    if( isset( $_GET['fetch'] ) ){
       $httpresponse = new stdClass();
       $fb_fetch = new foobar_fetcher();
       $httpresponse->data = $fb_fetch->getFoo();
    }
    
    echo json_encode( $httpresponse );
    

    Navigate to /ajaxdispatcher.php?fetch=fetch

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

Sidebar

Related Questions

Please consider a problem constructing an array and returning it to a parent object.
I have a soap request returning array of User objects. Now I want to
I have a problem returning data back to the function I want it returned
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have used a custom array adapter to populate my list view.The problem i
I have a problem with an array that is getting returned from a query
I have a problem with returning a list by executing a Select LINQ query.
I have an algorithm problem that I came across at work but have not
I have a recurring problem in templating projects. I can't really test my work
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

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.