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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -