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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:23:08+00:00 2026-06-13T19:23:08+00:00

i have a Json result that i got through a webservice, now i want

  • 0

i have a Json result that i got through a webservice, now i want to see if it works, how do i make that Json values show in a button or link? and on page load?

one of the values returned looks like this : “name”: “Muhammad Ali”,
“nickname”: “The Greatest”,

very new to json and javcascript.

Javascript and json :

    function Getdata() {
    $.ajax({
        type: "POST",
        data: "{}",
        url: "https://raw.github.com/appcelerator/Documentation-Examples/master/HTTPClient/data/json.txt",
        contentType: "application/json; cherset=utf-8",
        datatype: "json",
        success: loadpage,
        failure: givealert
    });



    function loadpage(result) {
        if (resu.hasOwnProperty("d")) { result = res.d; }
        var data = JQuery.parseJSON(result);
    }

    function givealert(error) {
        alert('failed!!' + error);
    }
}

now how do i get it to show one value from the web-service in a label and on form load?
html markup for the label/button :

 <div id="listheight">
                <a type="button" id="routing" href="#datatapage"></a>
            </div>

i am using cordova/phonegap,Visual studi2010, html, javascript, css, jquerymobile and jquery1.8.2.

thanks in advance!

  • 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-13T19:23:09+00:00Added an answer on June 13, 2026 at 7:23 pm

    First, use this HTML

    <a type="button" id="routing" href="#datatapage" onclick="Getdata()">Click</a> 
    

    Use this code to call the method automatically on pageload

    $(document).ready(function() {
      // this is executed on page load
      Getdata();
    });
    

    and change your code to

    jQuery.support.cors = true;
    
    function Getdata() {
      var request = $.ajax({
        type: "POST",
        data: "{}",
        dataType: 'json',
        url: "data/json.txt",  // better use a relative url here
        mimeType: "application/json; cherset=utf-8",
        success: loadpage,
        failure: givealert
      });
    
      function loadpage(result) {
        // this only displays you the values in a messagebox for you to check if it works
        // you can remove the following two lines
        alert("Name = "+result.fighters[0].name);
        alert("Nickname = "+result.fighters[0].nickname);
        // this changes the text
        document.getElementById("routing").innerHTML = result.fighters[0].name;
      }
    
      function givealert(error) {
        alert('failed!!' + error);
      }
    }
    

    I created a JSFiddle for this: http://jsfiddle.net/FUWyJ/
    Note that the URL i send the request to is provided by JSFiddle and points to https://gist.github.com/4001105 where I made a copy of your sample data.

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

Sidebar

Related Questions

I have a JSON result that contains numerous records. I'd like to show the
I have an asp.net mvc website that returns a JSON result to certain pages
I have my php coded page on one server that returns a json result.
I have ASP.NET page, it calls webservice via $.ajax and returns result in json
I have an JSON data in format of [{product_id:33,amount:1},{product_id:34,amount:3},{product_id:10,amount:1},{username:test}] now I want to fetch
I'm creating an iPhone app that consumes a json webservice. I have an NSURLRequest
I have made this so far. It's code that will make a json String
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z
I have the following result from geoPlugin http://www.geoplugin.net/json.gp?ip=64.90.182.55 : geoPlugin({ geoplugin_request:64.90.182.55, geoplugin_status:200, geoplugin_city:New York,
I have a outsource data from : http://example.com/data/news.json Here is the example result after

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.