javascript - Use same variable that is defined in another function -


this may seem simple less experienced javascript. have 2 functions. 1 called when upload begins. next called when upload ends.

in first function, variable created, unique id used upload. best way go reusing in second function since not global? reason defined within function because every time user clicks upload button, function called , new id created upload, why not want define outside because same id served second upload unless page refreshed.

anyone got suggestions?

function uploadstart() {      function makeid() {         var text = "";         var possible = "abcdefghijklmnopqrstuvwxyz0123456789";          for( var i=0; < 32; i++ )             text += possible.charat(math.floor(math.random() * possible.length));          return text;     }      var rand_id = makeid();  }  uploadfinish(){     //rand_id undefined } 

try declaring rand_id in global scope (before everything)

var rand_id; function bla.... 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -