Pergunta

Here's my problem

<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> 

The url returns this:

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
    )

)

Now, what I want to do is append the entry bitcoin_address to $continue '<?php echo $continue;?>'. which stands for: /index.php?route=checkout/success. so it would read /index.php?route=checkout/success&btc=1DJ9qiga2fe94FZPQZja75ywkdgNbTvGsW. it seems like it should be simple but I can't see how to do it.

The next page has a javascript function that parses the bitcoin address from the url and displays it on the page. This all works fine, I just can't get the bitcoin address to actually show!

Foi útil?

Solução

Make it return JSON. You will reduce the amount of pain a lot. Apparently it's PHP, so just use PHP's json_encode(), then just use the JSON response to concatenate stuff to url in your 'success' function.

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

...or something like that. Try console.log(data) if you're not sure what you're getting.

Outras dicas

Set a variable in global scope and then access it within functions

<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'];
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top