-1

这是我的问题

<script type="text/javascript"><!--
$('#button-confirm').bind('click', function() {
    $.ajax({ 
        type: 'GET',
        url: 'index.php?route=payment/bitcoinpayflow/confirm',
        success: function(url) {
             location = '<?php echo $continue;?>';
        }       
    });
});
//--></script> 

网址返回此:

https://bitcoinpayflow.com/ordersArray // note the lack of space between orders and array. Is this a problem? If it is, I can get it to display in JSON notation with some fiddling.
(
    [order] => Array
        (
        [bitcoin_address] => 1DJ9qiga2fe94FZPQZja75ywkdgNbTvGsW
    )

)

现在,我想做的是将条目 bitcoin_address 附加到 $continue '<?php echo $continue;?>'。代表:/index.php?route=checkout/success. 所以它会读/index.php?route=checkout/success&btc=1DJ9qiga2fe94FZPQZja75ywkdgNbTvGsW。看起来应该很简单,但我不知道该怎么做。

下一页有一个 javascript 函数,它从 url 解析比特币地址并将其显示在页面上。这一切都很好,我只是无法让比特币地址实际显示!

4

2 回答 2

0

让它返回 JSON。你会减少很多痛苦。显然它是 PHP,所以只需使用 PHP 的 json_encode(),然后只需使用 JSON 响应将内容连接到“成功”函数中的 url。

location = "<?php echo $location; ?>&btc=" + data.bitcoin;

...或类似的东西。如果你不确定你得到了什么,试试 console.log(data)。

于 2012-04-25T20:10:00.163 回答
0

在全局范围内设置一个变量,然后在函数中访问它

<script type="text/javascript"><!--
var btcaddress = null;

$('#button-confirm').bind('click', function() {
    if( isValidBtcAddress( btcaddress ) ){
      Url = 'index.php?route=payment/bitcoinpayflow/confirm' + btcaddress;
    }else{
      Url = 'index.php?route=payment/bitcoinpayflow/confirm';
    }

    $.ajax({ 
        type: 'GET',
        'url': Url,
        success: function(url) {
             location = '<?php echo $continue;?>';
        }       
    });
});



function someotherFunction( response ){
    btcaddress = response['order']['bitcoin_address'];
}
于 2012-05-30T13:55:53.173 回答