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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:50:19+00:00 2026-05-26T21:50:19+00:00

I have the following php object(??? new to this). It is being sent through

  • 0

I have the following php object(??? new to this). It is being sent through from my page via AJAX and was sent over as JSON. I’m decoding it and trying to echo the results, but all I get is NULL. In Firebug, everything in the POST widow shows up fine, but nothing in the RESPONSE (which I assume is where I’m supposed to look?)

header('Content-type: application/json');
$res = json_decode($_POST['apiresponse'], true);
echo $res;
  • The JSON object was passed to the above PHP file (also stringified before passing)
  • JSON was decoded and saved as $res variable
  • Everything shows fine in the Firebug POST window

How do I convert this into a PHP variable (string) that I can return to my original PHP page, and

How do I send / call the variable back?**

Thanks!

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

    this was not the case: (skip down!)
    how do you pass the variables from javascript on to php?
    i’m really just guessing here, but it sounds a lot like you have something along the lines of

    $.ajax( "/my-api-thing.php", { data: { "apiresponse": "some_value", "more":"things" } }).success(...);

    IF this is the case then you are only expecting json as a result from the php script, but you’re not actually sending a json object as a request, but normal http parameters.

    you would then just write something like this in php:

    $someVariable = $_POST["apiresponse"]

    (btw: this would be the “normal” way to do it, sending json to the server is not all that common)


    updated guess

    i’ve verified the json you’re posting with this file:

    <form type="textarea" method="post">
    <textarea name="apiresult" style="width: 400px;height:200px;">
        {"id":"-------","name":"Aaron ----------","first_name":"Aaron","last_name":"----","link":"http://www.facebook.com/-------","username":"-----","birthday":"05/06/1949","location":{"id":"-----","name":"Los Angeles, California"},"gender":"male","email":"------","timezone":-8,"locale":"en_US","verified":true,"updated_time":"2011-10-22T18:40:02+0000"}
    </textarea>
    <br>
    <input type="submit">
    </form>
    
    <br>
    
    
    <?php
    
    if( isset( $_POST["apiresult"] ) ){
        echo "<pre>"; 
        echo $apiresult; 
        echo "\n----\n"; 
        print_r( json_decode( $_POST["apiresult"] ) ); 
        echo "</pre>"; 
    }
    
    ?>
    

    so the json_decode doesn’t seem to be the problem at all.

    a few other guesses:

    1. you have a very old version of php a magic quotes are enabled (run phpinfo to check!)
    2. you’re using a php framework which does some preprocessing on post variables

    to pinpoint the problem, can you run an echo $_POST["apiresponse"]; just before the json_decode to see if the output differs from the output?

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

Sidebar

Related Questions

I'm just starting with Object Oriented PHP and I have the following issue: I
I have the following PHP code which works out the possible combinations from a
I have a html page that calls a php object to get some data
I have the following code in IndexController.php: $sql = 'SELECT * FROM ?'; $stmt
i have 2 objects, which are associated arrays from PHP in JSON. They have
I'm new to PHP DOM object and have a problem I can't find a
I have the following code: <?php require_once('IPTC.php'); $iptc = new Image_IPTC('001.jpg'); print_r($iptc); ?> And
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
Simple question but since I'm new to python, comming over from php, I get
Really stumped on this one. I have the following PHP file with a variable

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.