【发布时间】:2017-01-24 05:12:12
【问题描述】:
显示 json 数据的代码
$('body').on('click','#check_history',function () {
var settings = {
"async": true,
"crossDomain": true,
"url": "https://url.com",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"postman-token": "bla-bla-bla-bla"
},
"data": {
"userid": "this-is-userid",
"to": "destination",
"count": "5"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
//I think I need some code here
});
});
我从控制台中的 AJAX 获得以下 JSON 响应
{
"status": 0,
"trxid": "101010101",
"billpayQueryState": false,
"billpayState": false,
"trxList": [{
"date": "16/1/2017 11:51",
"transid": 1010101010,
"type": "merchant_buy",
"amount": 3500,
"agent": "abc"
}, {
"date": "16/1/2017 11:25",
"transid": 2020202020,
"type": "merchant_buy",
"amount": 4500,
"agent": "abc"
}, {
"date": "16/1/2017 11:5",
"transid": 3030303030,
"type": "merchant_buy",
"amount": 4500,
"agent": "abc"
}, {
"date": "16/1/2017 10:55",
"transid": 4040404040,
"type": "merchant_buy",
"amount": 5000,
"agent": "abc"
}, {
"date": "16/1/2017 10:39",
"transid": 5050505050,
"type": "merchant_buy",
"amount": 5500,
"agent": "abc"
}],
"agentData": {
"walletType": 0,
"isWaitingForKyc": false,
"isAllowToKyc": false,
"isOutlet": false
}
}
我需要将上面的 JSON 数据显示为易于人类阅读的表格或 html。我已经从 google 和 stackoverflow 尝试了很多方法,但没有解决我的问题。我该怎么做?请帮忙!
【问题讨论】:
-
包括您在 OP 中尝试过的内容
-
从尝试过的多种方法中展示任何一种方法,这有助于了解哪里出了问题
标签: javascript jquery html json ajax