验证比特币交易Json



我正试图通过一个示例请求,用我的应用程序的比特币URL JSON格式验证我的交易。我不知道在这个URL中我是否有我的案例的答案。我需要在列表中显示数据。我需要的信息是付款,可以。你能帮我吗?

请求:https://blockchain.info/tx/a47b5f0e31faaec5ff7d8d7c4662e174dae99ecbddd9bf32a846017b69c98794?format=json

$.ajax({
url:'https://blockchain.info/tx/a47b5f0e31faaec5ff7d8d7c4662e174dae99ecbddd9bf32a846017b69c98794?format=json',
type: 'POST',
dataType: 'HTML',
data: {param1: 'value1'},
})
.done(function(data) {
alert(data);
console.log("success");
//check the json and print result
$('#answer').html("<li>"+data+"</li>");
})
.fail(function(data) {
alert("Error: " + data);
console.log("error");
})
.always(function() {
console.log("complete");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div id="answer">waiting..</div>

我想我理解你的问题,所以你想获取数据,然后打印到DOM一个事务值列表,所以我使用fetch API来获取事务值,然后我获取在它们上迭代的事务,并创建一个";李;对于每个值并将其附加到DOM中,希望这能帮助您

let proxyUrl = 'https://cors-anywhere.herokuapp.com/'
const list = document.getElementById('values')
const renderValues = (values) => {
values.forEach(value => {
const element = document.createElement('li')
console.log(element)
element.innerHTML = value.value
list.appendChild(element)
})
}
fetch(proxyUrl + 'https://blockchain.info/tx/a47b5f0e31faaec5ff7d8d7c4662e174dae99ecbddd9bf32a846017b69c98794?format=json').then(data => data.json()).then(res => renderValues(res.out)).catch(err => console.error(err))
<div id="answer">
<ul id="values">
</ul>
</div>

最新更新