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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:21:37+00:00 2026-05-23T20:21:37+00:00

I have an extremely simple JSON object that looks like the following: var data

  • 0

I have an extremely simple JSON object that looks like the following:

var data =
{
    "id" : 1
}

I then decode this in PHP:

$decoded_data = json_decode(stripslashes($_POST['data']));  //this works
$id = intval($decoded_data->id); //in my debugger this is equal to 1 as expected

I then proceed to pass the $id variable into a function that queries the database and returns a set of ‘Sub Activities’

$sub_activities = alp_get_all_sub_activities($id);  //this function works as expected and returns the correct result set

Now that I have the Sub Activities for the designated $id, I attempt to access them using a loop:

foreach ($sub_activities as $activity) {
    echo __("<td><a id='" . $activity->id . "' href='' title='Activity'><div style=' border: 3px solid purple; width: 200px; height: 200px; overflow: scroll;'>" . $activity->name . "<br />" . $activity->id . "<br />" . $activity->description) . "</div></a></td>";
}

My problem is: echo displays nothing when $id is set to intval($decoded_data->id), but when I hardcode $id = 1 then everything works as expected and shows in my browser. I’m not quite sure how to approach this problem, because my debugger is telling me that when I set $id = intval($decoded_data->id); that $id is equal to 1. I can do arithmetic with this number and it seems like it behaves as any integer would, but for some reason echo and print() will not display anything.

If anyone has any insight I’d really appreciate your input.

  • 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-23T20:21:38+00:00Added an answer on May 23, 2026 at 8:21 pm

    This turned out to be a problem with ajax in WordPress with Buddypress installed. Buddypress was sending the request elsewhere for its own purposes. I just created my own javascript namespace object and rerouted the data. Here are tutorials that helped me figure this out:

    http://codex.wordpress.org/AJAX_in_Plugins

    http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/

    JSON now works perfectly. Thanks for the help!

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

Sidebar

Related Questions

I have an extremely simple control i'm trying to render which looks like this:
This might be extremely simple: I have a controller that returns a user object
I have an extremely simple page that isn't displaying properly in IE6. In this
I have an extremely simple script with PHP exec , calling mysql command: $dbhost
I have this extremely simple splash page here: http://iph0wnz.com It has the main graphic
I have an extremely simple BizTalk orchestration that takes a HIPAA 837 file in,
I am trying to create a usercontrol that is an extremely simple form. This
I have a simple class like the following: class Record { public Record(string fp1,
I have an extremely simple example trying to use Data Annotations with unobtrusive javascript
I have an extremely simple unit test. I'm not sure why it fails when

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.