【发布时间】:2015-01-27 21:39:57
【问题描述】:
我已经设法使用 JS 将 JSON 数据放入表单控件中:
$("#getRates").ready(function () {
$.getJSON("http://openexchangerates.org/api/currencies.json?app_id="APP_ID", function (data) {
console.log(data);
for (var value in data) {
if (data.hasOwnProperty(value)) {
var text = document.createTextNode(value);
var select = document.getElementsByClassName('form-control')[1];
select.appendChild(document.createElement('option')).appendChild(text);
}
}
当前的 JSON 文件仅包含国家/地区名称,但我希望使用名为 Latest.JSON 并包含最新汇率的不同 JSON 文件,但它具有以下字段:
“许可证”: “时间戳”:1417258840, “基础”:“美元”, “费率”:{ “AED”:3.672743, “AFN”:57.800375,
我怎样才能将“费率”附加到表单功能并使用费率进行转换?
正如我之前尝试过的那样,我只是 console.log 并收到“License”“timestamp”“base”但没有费率?
没有具体的答案,也许只是一些寻找方向的方向?
【问题讨论】:
标签: javascript jquery html json api