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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:21:03+00:00 2026-05-29T05:21:03+00:00

I used Json to get data off a site build in WordPress (using the

  • 0

I used Json to get data off a site build in WordPress (using the Json API plugin). I’m using jQuery mobile for the layout of the application in Phonegap. Getting the data to display in Phonegap wasn’t the hardest thing to find (code below). But, is it possible to make a list of the titles of different posts and linking them to the specific article and loading the content in a page? In PHP you could just use an argument but is there a way to make something like this work in jQuery mobile?

Here’s code I used. Also handy if someones happens to come across this post using google.

    <script>          
        $(document).ready(function(){
            var url="http://127.0.0.1:8888/wp/api/get_recent_posts";
            $.getJSON(url,function(json){
                $.each(json.posts,function(i,post){
                    $("#content").append(
                    '<div class="post">'+
                    '<h1>'+post.title+'</h1>'+
                    '<p>'+post.content+'</p>'+
                    '</div>'
                    );
                });
            });
        });
    </script> 

EDIT:

I’d like to thank shanabus again for helping me with this. This was the code I got it to work
with:

    $(document).ready(function() {

        var url="http://127.0.0.1:8888/wpjson/api/get_recent_posts";
        var buttonHtmlString = "", pageHtmlString = "";

        var jsonResults;

        $.getJSON(url,function(data){
            jsonResults = data.posts;
            displayResults();       
        });

        function displayResults() {

            for (i = 0; i < jsonResults.length; i++) {
                buttonHtmlString += '<a href="#' + $.trim(jsonResults[i].title).toLowerCase().replace(/ /g,'') + '" data-role="button">' + jsonResults[i].title + '</a>';
                pageHtmlString += '<div data-role="page" id="' + $.trim(jsonResults[i].title).toLowerCase().replace(/ /g,'') + '">';
                pageHtmlString += '<div data-role="header"><h1>' + jsonResults[i].title + '</h1></div>';
                pageHtmlString += '<div data-role="content"><p>' + jsonResults[i].content + '</p></div>';
                pageHtmlString += '</div>';
            }

            $("#buttonGroup").append(buttonHtmlString);
            $("#buttonGroup a").button();
            $("#buttonGroup").controlgroup();
            $("#main").after(pageHtmlString);
        }

    });
  • 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-29T05:21:03+00:00Added an answer on May 29, 2026 at 5:21 am

    Yes, this is possible. Check out this example: http://jsfiddle.net/shanabus/nuWay/1/

    There you will see that we take an object array, cycle through it and append new buttons (and jqm styling). Does this do what you are looking to do?

    I would also recommend improving your javascript by removing the $.each and substituting it for the basic for loop:

    for(i = 0; i < json.posts.length; i++)
    

    This loop structure is known to perform better. Same with the append method. I’ve heard time and time again that its more efficient to build up a string variable and append it once rather than call append multiple times.

    UPDATE

    In response to your comment, I have posted a new solution that simulates loading a Json collection of content objects to dynamically add page elements to your application. It also dynamically generates the buttons to link to them.

    This works if you do it in $(document).ready() and probably a few other jQM events, but you may have to check the documentation on that or call one of the refresh content methods to make the pages valid.

    http://jsfiddle.net/nuWay/4/

    Hope this helps!

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

Sidebar

Related Questions

Since getJSON() method is used to get JSON data using an AJAX HTTP GET
I'm using ASIHTTPRequest API to get some JSON data from a web side. I'm
I have been using jQuery lately, but never used JSON with it. Now, I
I used var dp:ArrayCollection = new ArrayCollection(container.GetVotesResult); to get the JSON data from GetVotesResult
I need to get json data from an external domain. I used WebRequest to
Previously i have used restful wcf webservices to get the data from server.But now
I have problem .. i get debugerror i will used in json Category *selectcategory
I am using a method in which json and php are used to dynamically
When I get some json data I want to display them in the page
I want to serve jsonp so other sites can get json data from my

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.