I try to get a div refreshed with jQuery.
<div class="col-lg-8" id="btc"> Send <?php echo $bitcoin_price; ?></div>
<script>
$(document).ready(function () {
var interval = setInterval(refresh, 5000);
});
function refresh() {
$.get('site', function (result) {
$('#btc').html(result);
});
}
</script>
$bitcoin_price:
$url = "https://bitpay.com/api/rates";
$json = file_get_contents($url);
$data = json_decode($json, true);
// $data[1] = USD
$rate = $data[1]["rate"];
$usd_price = 10; # Let cost of elephant be 10$
$bitcoin_price = round($usd_price / $rate, 8);
Anyone knows how to to get this div refreshed with an interval and execute the request?
Or is this not possible? Do i need to include and refresh a file with ajax?