这是我的问题
<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中的比特币地址并将其显示在页面上。这一切都很好,我只是无法获得实际显示的比特币地址!
答案 0 :(得分:1)
让它返回JSON。你会减少很多痛苦。显然它是PHP,所以只需使用PHP的json_encode(),然后只需使用JSON响应将内容连接到“成功”函数中的url。
location = "<?php echo $location; ?>&btc=" + data.bitcoin;
......或类似的东西。如果你不确定你得到了什么,请尝试使用console.log(数据)。
答案 1 :(得分:1)
在全局范围内设置变量,然后在函数
中访问它<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'];
}