Passing AJAX GET results to location

0 votes

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!

Sep 4, 2018 in Blockchain by slayer
• 29,050 points
40 views

2 answers to this question.

0 votes

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.

answered Sep 4, 2018 by digger
• 27,640 points
0 votes

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'];
}
answered Sep 4, 2018 by eddy

Related Questions In Blockchain

0 votes
1 answer
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
68 views
0 votes
1 answer

How to get the already existing channels in Hyperledger v1.0?

You cannot see all available channels,  but you ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,020 points
220 views
0 votes
1 answer

How to get current block number in parity?

You can get the latest block number ...READ MORE

answered Jun 8, 2018 in Blockchain by Christine
• 15,790 points
195 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
75 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
138 views
0 votes
1 answer
0 votes
1 answer

How to get results by running the voting code on Ethereum?

In mist go to your contract and ...READ MORE

answered Sep 18, 2018 in Blockchain by digger
• 27,640 points
30 views
0 votes
1 answer

how to get modification history of asset?

You can use GetHistoryForKey() API as shown ...READ MORE

answered Jul 9, 2018 in Blockchain by digger
• 27,640 points
327 views