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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:06:17+00:00 2026-05-23T17:06:17+00:00

Parsing JSON in PHP My variable jsonvar is in the form of {rating:good} Once

  • 0

Parsing JSON in PHP

My variable jsonvar is in the form of {“rating”:”good”}

Once I push it through with this $.ajax code to submit, I’m a bit confused at what my PHP (jsonproc.php) should look like.

$.ajax({
                url: 'jsonproc.php',
                data: {js:jsonvar},
                dataType: 'json',
                type: 'post',
                success: function (j) {
                        if (j.ok){
                            alert(j.msg);
                        } else {
                            alert(j.msg);
                        }
                    }
                });

I have it set up as

$decoded = $_GET['js'];
$response = array(
   'ok' => true, 
   'msg' => $decoded['rating']);

However when I echo it back,

   echo json_encode($response);

using alert(j.msg) shows a “null” value.

Assuming that I am passing JSON in correctly, how can I point to the rating and get the value of “good”?

Thanks

EDIT

SOLVED, USING $_REQUEST I was able to get the JSON, however $_GET did not work.

Also, the key was using $decoded->{‘rating’} as $decoded is no longer just an array i don’t think or rather it’s a diff type of one?

  • 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-23T17:06:17+00:00Added an answer on May 23, 2026 at 5:06 pm

    It looks like you’re mixing data types here:

     data: "js="+jsonvar,
    

    jQuery will convert JSON if you pass an object, but you’re mixing query string with JSON.

    Try:

    data: {js: jsonvar},
    

    You may also need to do json_decode($_GET[‘js’]).

    edit: You can double check what jQuery is POSTing with Firebug/Web Inspector. Easiest way to know for sure.

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

Sidebar

Related Questions

I've having issues with parsing JSON data from a php file through to JQuery.I've
I'm fetching the JSON timeline from twitter and parsing it through PHP. I then
From a previous question on Stackoverflow Iterating through/Parsing JSON Object via JavaScript .... My
I have a php file that is only accessed through ajax. The ajax call
I am trying to test a few ajax and JSON parsing examples using YUI3
I have the following php object(??? new to this). It is being sent through
As the title says, I have slickgrid getting/parsing JSON data from PHP, but while
I need to create a dynamic html table using PHP after parsing a JSON
I'm having trouble parsing a json response. Its created via php and sent back
i am trying to Json parsing in my android app the link is https://www.buzzador.com/apps/present_software/webservice/index.php?op=ProductQ&campaign_id=607&userid=10776

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.