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

  • Home
  • SEARCH
  • 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 8152063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:36:07+00:00 2026-06-06T15:36:07+00:00

I’m exporting my php as jsonp and then calling a js file which loads

  • 0

I’m exporting my php as jsonp and then calling a js file which loads in the data.

I’m getting the output of only the last data object. I would like to loop through the action data and have all of them output into the <li>data.action</li> format. If anyone can help figure how to do this thank you so much.

JSONP

({
    "posts": [{
        "action": "go to acting school",
        "action": "go to a beach",
        "action": "go kyacking",
        "action": "go skiing in vermont",
        "action": "sleep in a cave",
        "action": "dress up as favorite celebrity in public",
        "action": "see the cherry blossums in Washington DC",
        "action": "watch all the rocky movies",
        "action": "go sky diving",
        "action": "climb Mount Everest",
        "action": "climb K2",
        "action": "see or participate in war reenactment",
        "action": "spend New Years Eve in Times Square",
        "action": "jump out of a moving plane",
        "action": "jump out of a moving car",
        "action": "try eating a new food"
    }]
})

JQUERY

 $(document).ready(function () {
     $.getJSON("http://site.com/lesson.php?count=5&jsoncall=?", function (data) {
         $.each(data.posts, function (i, data) {
             var jsondata = "<li>" + data.action + "</li>";
             $(jsondata).appendTo("ol#results");
         });
     });
     return false;
 });
  • 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-06T15:36:10+00:00Added an answer on June 6, 2026 at 3:36 pm

    That isn’t proper json. When converted to a javascript object, it will contain:

    {
        "posts": [{"action": "try eating a new food"}]
    }
    

    This is what i believe it should be instead:

    {
        "actions": ["go to acting school","go to a beach","go kyacking","go skiing in vermont","sleep in a cave","dress up as favorite celebrity in public","see the cherry blossums in Washington DC","watch all the rocky movies","go sky diving","climb Mount Everest","climb K2","see or participate in war reenactment","spend New Years Eve in Times Square","jump out of a moving plane","jump out of a moving car","try eating a new food"]
    }
    

    Obviously this is with no knowledge of what the json actually represents. The thinking behind the change i made is if they are all actions, place them all in one array that is stored in a property called actions

    You would then output it with:

    var myStr = "";
    $.each(data.actions, function (i, action) {
        myStr += "<li>" + action + "</li>";
    });
    $("#results").append(myStr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,

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.