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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:14:38+00:00 2026-06-07T20:14:38+00:00

I have really been searching for almost 2 hours and have yet to find

  • 0

I have really been searching for almost 2 hours and have yet to find a good example on how to pass JSON data from PHP to JS. I have a JSON encoding script in PHP that echoes out a JSON script that looks more or less like this (pseudocode).

{
"1": [
  {"id":"2","type":"1","description":"Foo","options:[
    {"opt_id":"1","opt_desc":"Bar"},
    {"opt_id":"2","opt_desc":"Lorem"}],
  {"id":"3","type":"3","description":"Ipsum","options:[
...
"6":
  {"id":"14","type":"1","description":"Test","options:[
...
etc

Problem is, how can I get this data with JavaScript? My goal is to make a .js script that generates a poll based on these JSON datas, but I honest to god can’t find any examples on how to do this. Guessing it is some something like:

Obj jsonData = new Object();
jsonData = $.getJson('url',data,function()){
  enter code here
}

Any links to any good examples or similar would be highly appreciated. And I thought that encoding the data in PHP was the tricky part…

EDIT:

I got this code snippet to work, so I can review my whole JSON data in JS. But now I can’t seem to figure out how to get to the inner data. It does print out the stage number (1-6) but I can’t figure out how to get the question data, and then again the options data within each question. Do I have to experiment with nested each loops?

$(document).ready(function()
    {       
        $('#show-results').click(function() 
        {
            $.post('JSAAN.php', function(data) 
            {
                var pushedData = jQuery.parseJSON(data);
                $.each(pushedData, function(i, serverData)
                {
                    alert(i);
                })
            })
        })
    });

The idea here is to get into the question information in the middle level and print out the qusetion description, then based on the question type – loop through the options (if any) to create checkbox/radiobutton-groups before going on to the next question. The first number represents which stage of the multi stage poll I am currently working on. My plan is to divide it into 6 stages by hiding/showing various divs until the last page where the form is submitted through Ajax.

  • 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-07T20:14:40+00:00Added an answer on June 7, 2026 at 8:14 pm

    Not sure but I think, you can use

    $.getJSON('url', data, function(jsonData) {                       
      // operate on return data (jsonData)    
    });
    

    now you can access and operate on the PHP json data,
    if you’re going to use it outside the getJson call you can assign it to a variable

    var neededData; 
    $.getJSON('url', data, function(jsonData) {
        neededData = jsonData; 
    });       
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching for how to retrieve binary data from the database. My
I have been searching how to display data from a xml file in a
I have been looking around the web for this but cannot really find a
Hi I have been searching though research papers on what features would be good
I need some help, i have been searching around and cant find the correct
I have been searching on google for this and am not able to find
I've been searching all over for tips on this and have not really had
I've been searching online but haven't really found anything definitive. Lets say I have
I have been searching this since yesterday and still nothing. From all that researching
I have been searching in Google etc., but I couldnt find what I was

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.