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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:32:10+00:00 2026-06-14T12:32:10+00:00

I am using a online tutorial to lean how to create a web service,

  • 0

I am using a online tutorial to lean how to create a web service, generate a JSON object, send it back to my Win 8 App and display it. The web service is working however I am struggling to return a value to the APP. My code in the app is:

 WinJS.xhr({                         
         url: 'http://localhost/filmgloss/web-service.php?termID=1&format=JSON'
     })
         .done(
            function complete(result) {

                // terms is the key of the object
                for (var terms in result) {

                    for (var term in terms) {


                        if (result.hasOwnProperty(term)) {
                            //here you have to acess to
                            var termName = result[term].termName;
                            var def = result[term].definition;
                        }
                        //Show Terms                 
                        testDef.innerText = definition;
                    }
                }
            },

And he code in my web service is:

if($format == 'json') {
   header('Content-type: application/json');
   echo json_encode(array('terms'=>$terms));
}else...

The JSON output itself looks like:

    {"terms":[{"term":{ "termName":"Focus","definition":"A Focus..."}}]}

I am using a for..in but whilst I can look inside terms' I can't work out how to look interm`

  • 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-14T12:32:12+00:00Added an answer on June 14, 2026 at 12:32 pm

    I have managed to resolve my issue with the help of a developer friend. My problem was that I had not realised that the result of WinHS.xhr was not already a JSON Array. Although my web-service outputs a JSON Array when it is consumed through WinHS.xhr it appears to be returned as an XMLHttpRequest object.

    The solution was therefore to process the result using:

    JSON.parse(result.responseText)

    I could then use a For...In loop as expected:

      for (terms in responseTerms) {
    
                 //terms will find key "terms"
                 var termName = responseTerms.terms[0].term.termName;
                 var termdefinition = responseTerms.terms[0].term.definition;
    
                 testTerm.innerText = termName;
                 testDef.innerText = termdefinition;
    
             }
    

    Thanks for everyone that commented, hopefully this may help others in the future if they’re starting out with Win 8 app development.

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

Sidebar

Related Questions

I'm practicing on Django and using some online tutorial to build a web blog.
Im looking for any tutorial for online booking and reservation using php and mysql.
does anyone know if there's any good online tutorial for building pivot tables using
For my first time using Xcode I was following a tutorial online. I did
i follow the tutorial online , created an app for scanning barcodes and QR
I created a form in Excel 2003 using a tutorial online but I had
I'm just starting out Perl (about 15 minutes ago) using a tutorial online. I
I was searching online for a tutorial to create a form which is displyaed
Anyone who's tried to study mathematics using online resources will have come across these
Ok. I just installed Qt from: http://qt.nokia.com/downloads using the online installer. I have MinGW,

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.