オンラインチュートリアルを使用して、Webサービスの作成方法、JSONオブジェクトの生成方法、Win 8アプリへの返送方法、および表示方法を学習しています。Webサービスは機能していますが、APPに値を返すのに苦労しています。アプリの私のコードは次のとおりです。
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;
}
}
},
そして、彼は私のWebサービスのコードを次のようにしています。
if($format == 'json') {
header('Content-type: application/json');
echo json_encode(array('terms'=>$terms));
}else...
JSON出力自体は次のようになります。
{"terms":[{"term":{ "termName":"Focus","definition":"A Focus..."}}]}
私は使ってfor..in
いますが、用語の内部を見ることができますterms' I can't work out how to look in
`