Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将结果值传递到新选项卡_Javascript_Bitcore - Fatal编程技术网

Javascript 将结果值传递到新选项卡

Javascript 将结果值传递到新选项卡,javascript,bitcore,Javascript,Bitcore,我使用带有Bitcore和JavaScript的比特币应用程序,并使用下面提供的功能获取控制台日志- function getTransactions() { var result = {}; var address = $('#address').find(":selected").text(); var explorers = require('bitcore-explorers');

我使用带有
Bitcore
JavaScript
的比特币应用程序,并使用下面提供的功能获取控制台日志-

   function getTransactions() {

                var result = {};
                var address = $('#address').find(":selected").text();
                var explorers = require('bitcore-explorers');
                var client = new explorers.Insight('testnet');

                client.getUnspentUtxos(address, function (err, transactions) {
                    result.transactions = transactions;

                    var len = result.transactions.length;

                    for (i = 0; i < len; i++) { 

                        console.log(result.transactions[i].address.toString());
                        console.log(result.transactions[i].amount);
                    }

                    setConsoleData('', result);
                });
            };
对于
console.log(result.transactions[i].amount),我得到
未定义的
打印输出。当我尝试使用
amount.toString()
时,当它试图获取
未定义的
toString()
时,我得到了一个错误

当我使用code
window.open('transactions.html?result='+result)时
设置控制台数据
之后,我可以打开一个新选项卡,其
URL
值为

file:///Users/Myelan/Documents/Projects/Wallet-App-JS/transactions.html?result=[对象%20对象]

我需要在新的
HTML
选项卡中包含所有交易及其
地址、金额和txid
,我需要知道如何将
结果
值传递到新选项卡

我怎样才能做到这一点

Note
当我编写代码
result=JSON.parse(result)时,我在控制台中得到以下打印结果


使用
result=JSON.parse(result)
将json响应字符串解析为
json
对象

function getTransactions() {
    var result = {};
    var address = $('#address').find(":selected").text();
    var explorers = require('bitcore-explorers');
    var client = new explorers.Insight('testnet');

    client.getUnspentUtxos(address, function (err, transactions) {
        result.transactions = JSON.parse(transactions);
        var len = result.transactions.length;

        for (i = 0; i < len; i++) { 

            console.log(result.transactions[i].address.toString());
            console.log(result.transactions[i].amount);
        }

        setConsoleData('', result);
    });
};
函数getTransactions(){ var result={}; 变量地址=$(“#地址”).find(“:selected”).text(); var explorers=require('bitcore-explorers'); var client=newexplorers.Insight('testnet'); client.getUnpentutXOS(地址、函数(错误、事务){ result.transactions=JSON.parse(事务); var len=result.transactions.length; 对于(i=0;i
代码不起作用,请参阅问题的更新。此外,问题是,我需要将
result
obj传递到新选项卡,并需要在新的
HTML
页面中获取所有事务。如何做到这一点?顺便说一句,使用
JSON
我必须导入
任何东西吗?你必须使用
result.transactions=JSON.parse(transactions)我更新了答案。要在新窗口中获取所有结果对象,必须将每个属性作为查询字符串传递。我仍然会得到相同的错误。此外,您能否提供示例代码,说明如何在新窗口中传递
结果并对其进行解密?请参见重定向到transactions.html页面中的示例,您可以将url json字符串解析回json对象
function getTransactions() {
    var result = {};
    var address = $('#address').find(":selected").text();
    var explorers = require('bitcore-explorers');
    var client = new explorers.Insight('testnet');

    client.getUnspentUtxos(address, function (err, transactions) {
        result.transactions = JSON.parse(transactions);
        var len = result.transactions.length;

        for (i = 0; i < len; i++) { 

            console.log(result.transactions[i].address.toString());
            console.log(result.transactions[i].amount);
        }

        setConsoleData('', result);
    });
};