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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:41:24+00:00 2026-05-21T08:41:24+00:00

I have this bit of javascript: var jsonString = some string of json; $.post(‘proxy.php’,

  • 0

I have this bit of javascript:

var jsonString = "some string of json";
$.post('proxy.php', { data : jsonString }, function(response) {
    var print = response;
    alert(print);

and this bit of PHP (in proxy.php):


       $json = $_POST['json'];

       //set POST variables, THIS IS WHERE I WANT TO POST TO!
       $url = 'http://my.site.com/post';

       //open connection
       $ch = curl_init();

       //set the url, number of POST vars, POST data
       curl_setopt($ch,CURLOPT_URL, $url);
       curl_setopt($ch,CURLOPT_POST, 1);
       curl_setopt($ch,CURLOPT_POSTFIELDS, "data=" . urlencode($json));

       //execute post (the result will be something like {"result":1,"error":"","pic":"43248234af832048","code":"234920348239048"})
       $result = curl_exec($ch);
       $response = json_decode($result);

       $imageHref = 'http://my.site.com/render?picid=' . $response['picid'];

       //close connection   
       curl_close($ch);

       echo $imageHref;

I am trying to post data to an external site using a proxy. From there, I append the picid that the site responds with and append it to the URL to get the image URL.

Am I missing something here? I am not getting anything in response and it seems like my data is not even being posted (when I try echo $json after the first line in proxy.php, I get an empty string). Why am I not able to echo the JSON? Is my implementation correct?

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-21T08:41:25+00:00Added an answer on May 21, 2026 at 8:41 am

    In your Javascript code, you are using this :

    { data : jsonString }
    

    So, from your PHP code, should you not be reading from $_POST['data'], instead of $_POST['json'] ?

    If necessary, you can use var_dump() to see what’s in $_POST :

    var_dump($_POST);
    

    Edit after the comment : if you are getting a JSON result such as this :

    {"result":1,"error":"","pic":"43248234af832048","code":"234920348239048"}
    

    This is a JSON object — which means, after decoding it, you should access it as an object in PHP :

    $response = json_decode($result);
    echo $response->pic;
    

    Note : I don’t see a picid element in that object — maybe you should instead use pic ?

    Here too, though, you might want to use var_dump(), to see how your data looks like :

    var_dump($response);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this bit of javascript written with jQuery 1.2.5. It's contained inside the
I'm pulling my hair out over this. I have this bit of javascript that
I have this bit of script to widen a text box on mouseover and
I have this bit of code I found on the web at the end
Well, I have this bit of code that is slowing down the program hugely
This a bit of strange one.... We have an internal web app that runs
Ok - a bit of a mouthful. So the problem I have is this
I have a table that looks a bit like this actors(forename, surname, stage_name); I
This is a bit of a stretch, but I have an interesting (to me)
I have a database that contains a table that looks a bit like this:

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.