javascript - onbeforeunload function empty fields -


i have function save needs called on onbeforeunload event. code:

var data = new array(); window.onbeforeunload = save;  function save(){      console.log(data); }  function update(){     data.push('test'); } setinterval(update, 100); 

the data array empty when save method gets called. in field lots of 'test' elements. why empty?

you need return test anything.

function save(){      console.log(data);       return "testing console output"; } 

this working fine me.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -