2012-01-25 13 views
0

私はJqueryを使用してこのクエリYQLを解析できます。 私 はあなたに感謝し、非常にParse Currency YQL with Jquery

JSON情報を見ることができない

{ 
"query": { 
    "count": 2, 
    "created": "2012-01-25T18:58:01Z", 
    "lang": "en-US", 
    "results": { 
    "span": [ 
    { 
    "id": "yfs_l10_audmxn=x", 
    "content": "13.8172" 
    }, 
    { 
    "id": "yfs_l10_audmxn=x", 
    "content": "13.8172" 
    } 
    ] 
    } 
} 
} 

のjQuery

 <script> 
     $(function(){ 
      $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){ 
       $('#currency').html(data.query['results'].span); 
      }); 
     }); 
    </script> 

TNKS =)

+0

ここで質問がありますか? – Treffynnon

答えて

1

通貨情報があります。なぜあなたはそれを見ていないのかわかりません。

$('#currency').html(data.query['results'].span[0].content); 

data.query['results'].span[0].content

13.8172が含まれている、あなたがこれを使用する必要がありますように。
Thats means MXN 1 = AUD 13.8172

+0

ありがとうございます。私は正しく働いた – yorkfx

0
$(function(){ 
      $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmx.finance.yahoo.com%2Fq%3Fs%3DAUDMXN%3DX%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22yfs_l10_audmxn%3Dx%22%5D'&format=json&callback=", function(data){ 
     $("span").html(data.query.count); 
     $("#created").html(data.query.created); 
     $("#lang").html(data.query.lang); 
$(data.query.results.span).each(function(index,elem){ 
$.each(elem,function(k,v){ 
    $("<tr/>").append("<td> "+k+" </td><td> "+v+" </td>").appendTo("table"); 
    }) 
    }); 
    }); 
}); 

DEMO

+0

ありがとうございます – yorkfx

+0

あなたは大歓迎です – Rafay