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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:06:25+00:00 2026-06-12T00:06:25+00:00

This is probably easy but I could really use someone wiser in the ways

  • 0

This is probably easy but I could really use someone wiser in the ways of Ajax and JSON to help here. I have Javascript function passing an Ajax request to a PHP backend. I’m passing a javascript object as the “request_parameters” post variable. When this shows up on PHP I’m able to navigate it but the object structure has been replaced with arrays. Instead I’d like the object structure to remain intact so being the smart-enough-to-be-dangerous type I decide to JSON encode the object:

 request_parameters: JSON.encode( requestObj );

versus just

 request_parameters: requestObj;

On the PHP side I now get this as the value of the “request_parameters” variable (aka, $_POST[‘request_paramenters’]):

{\”forms\”:[{\”formName\”:\”main-form\”,\”formClass\”:\”lg-form main-form\”,\”formFields\”:[{\”id\”:\”activity-app_id\”,\”name\”:\”activity-app_id\”,\”value\”:\”0\”,\”type\”:\”hidden\”,\”startingValue\”:null},{\”id\”:\”activity-start_time\”,\”name\”:\”activity-start_time\”,\”value\”:\”\”,\”type\”:\”hidden\”,\”startingValue\”:null},{\”id\”:\”min-duration\”,\”name\”:\”min-duration\”,\”class\”:\”span1 form-ignore\”,\”value\”:\”50\”,\”type\”:\”text\”,\”startingValue\”:null},{\”id\”:\”activity-duration\”,\”name\”:\”activity-duration\”,\”value\”:\”3000000\”,\”type\”:\”hidden\”,\”startingValue\”:null},{\”id\”:\”exercise-distance\”,\”name\”:\”exercise-distance\”,\”class\”:\”input span1 left\”,\”value\”:\”25\”,\”type\”:\”text\”,\”startingValue\”:null},{\”id\”:\”exercise-distance-uom\”,\”name\”:\”exercise-distance_uom\”,\”value\”:\”miles\”,\”type\”:\”hidden\”,\”startingValue\”:null},{\”id\”:\”exercise-pace_average\”,\”name\”:\”exercise-pace_average\”,\”value\”:\”2\”,\”type\”:\”hidden\”,\”startingValue\”:null},{\”id\”:\”wp_posts-post_content\”,\”name\”:\”wp_posts-post_content\”,\”class\”:\”span5\”,\”value\”:\”super fast\”,\”type\”:\”textarea\”,\”startingValue\”:null}]}],\”action\”:\”went-running\”,\”post_type\”:\”exercise\”,\”primaryForm\”:0}

Ok, so this clearly got encoded so that the data would pass as a POST/GET variable without bad things happening. Fair enough. I figured I could address this on the PHP side by employing a decode before running the json_decode function. I first tried:

$request_parameters = json_decode( urldecode($request_parameters) );

Thought for sure this would be a winner. Nope. It didn’t give an error but $request_parameters seems to not be set to anything. Ok, then I went a little nuts and thought … “hey maybe the javascript used base64 encoding” … that led me to:

$request_parameters = json_decode( base64_decode($request_parameters) );

Bad juju. I’ll leave it there.

Any help would be greatly 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-06-12T00:06:26+00:00Added an answer on June 12, 2026 at 12:06 am

    Try json_decode(stripslashes($_POST['request_parameters']));

    You have probably got magic_quotes enabled.

    [Edited]

    If you have got Magic Quotes enabled, check the link provided in the comment below and disable it. If you use stripslashes blindly and later change the server settings or move to a different server, the above code will break.

    If however disabling Magic Quotes is not a possible option in your case, then use the below code for stripping the slashes from this particular post parameter.

    if (get_magic_quotes_gpc()) {
      $request_parameters = stripslashes($_POST['request_parameters']);
    }
    $request_parameters = json_decode($request_parameters);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably really easy for a pro, but could someone re-write this from it's PHP
Quick question- I know this is probably really easy, but my excel skills have
This is probably really easy but I can't seem to figure out how to
This is probably really easy, but I'm lost on how to make sure it
I feel really dumb for asking this question, but here it goes. I have
Now this is probably really easy but being the tool that I am, I'm
This is probably a really easy question to answer, but for some reason I'm
This is probably an easy solution but I can't get my head around it.
Morning y'all This is probably an easy one but I barely got any sleep
Ok, I think this is probably an easy question but for the life of

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.