首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为Foreach提供的Ajax无效参数()

为Foreach提供的Ajax无效参数()
EN

Stack Overflow用户
提问于 2018-12-19 00:49:56
回答 1查看 0关注 0票数 0

我有这个问题,但在此代码正常执行后所有其余功能。

控制台日志中的问题显示为“为Foreach提供的无效参数()第170行”

{“readyState”:4,“responseText”:“ \ n 警告:在第170行的/home/public_html/fetch.php中为foreach()提供的参数无效 \ n \ n 警告:为/中的 foreach()提供的参数无效第170行的home / public_html / fetch.php \ n \ n 警告:在第170行的/home/public_html/fetch.php中为foreach()提供的参数无效\ n \ n \ n \ n \“{\ n”状态\“:\”1 \“, \“text \”:\“<\ / i>付款成功。请稍等... \“}”,“状态”:200,“statusText”:“parsererror”}

我正在使用ajax加载此page.php代码

$passphrases = [ strToHex('alpha1'), strToHex('alpha1alpha2'), strToHex('alpha1alpha2alpha3'), strToHex('alpha1alpha2alpha3alpha4') ];
$keys = [ $block_io->initKey()->fromPassphrase($passphrases[0]), $block_io->initKey()->fromPassphrase($passphrases[1]), $block_io->initKey()->fromPassphrase($passphrases[2]), $block_io->initKey()->fromPassphrase($passphrases[3]) ];

$pubKeyStr = $keys[0]->getPublicKey() . "," . $keys[1]->getPublicKey() . "," . $keys[2]->getPublicKey() . "," . $keys[3]->getPublicKey();


foreach ($keys as &$key) {
    foreach ($getWd['data']['inputs'] as &$input) {
        // iterate over all the inputs

        $dataToSign = $input['data_to_sign']; 
        foreach ($input['signers'] as &$signer) {
            // iterate over all the signers for this input
            // find the key that can sign for the signer_public_key
            if ($key->getPublicKey() == $signer['signer_public_key'])
            { // we found the key, let's sign the data

              $signer['signed_data'] = $key->signHash($dataToSign);
            }
        }
    }
    // all the data's signed for this public key, let's give it to Block.io
    $json_string = json_encode($getWd['data']);

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'https://block.io/api/v2/sign_transaction/?api_key='.$apiKey.'&signature_data='.$json_string.'');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, ''.SITENAME.' API PURCHASE');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
$r1 = json_decode($query, true);

    $counter += 1; 

    if ($counter == 3) { break; }
}

在该代码之后我更新数据库并向我的会员发送电子邮件。如果我在xampp localhost中尝试此代码,它在console.log中没有任何错误,但在我上传到我的主机之后工作完美。它给了我这样的错误

有人知道怎么修复这个问题吗?请帮忙

EN

回答 1

Stack Overflow用户

发布于 2018-12-19 10:44:47

如果我做对了,你的json就会逃脱 - 而且无效。所以它是200状态,但不是有效的对象/数组

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100008941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档