javascript - php value refreshes every 10s but I want it to load instantly with page -
i'm using following code push last bitcoin price placeholder field of input textbox every 10 seconds:
var auto_refresh = setinterval( function() {$.get('gox.php', function (data) { $("#inputid").attr('placeholder', data); });}, 10000);
gox.php outputs value (e.g. 99.9999)
the problem when load page placeholder remains blank (since set placeholder="" in html) , doesn't refresh bitcoin price until 10 seconds have passed (the 10000 see in code).
i have tried:
function() {$.get('gox.php', function (data) { $("#inputid").attr('placeholder', data); });}
but doesn't work.
my goal have bitcoin price populate placeholder value page loaded , refresh every 10 seconds.
thanks in advance help!
var refreshbitcoin = function() { $.get('gox.php', function (data) { $("#inputid").attr('placeholder', data); }); }
at bottom of page (or within jquery ready block)
refreshbitcoin(); setinterval(refreshbitcoin, 10000);
Comments
Post a Comment