javascript - How do I re-initialize values in a function resides in document.ready? -


i have html file has following code,

<div id="pp-photo-wrap">     <input id="fileupload" type="file" name="files[]">       //added debug     <input id="debug" type="button" value="print design" onclick="alert(globalvars.selecteddesignid)" />     <script>     $j(document).ready(function(){             $j('#fileupload').fileupload({                 datatype: 'json',                 url: 'productpage/uploadphoto?design='+ globalvars.selecteddesignid,                 done: function (e, data) {                     enablephotostudio(data);                 }                        });     });     </script> </div> 

and have js file following function heaps of stuff , among following,

function clickdesignitem(item_el) {       ...       ...       globalvars.selecteddesignid = item_el.data('design_id');       ...       ...  } 

so problem want pass current globalvars.selecteddesignid in fileupload() function along url. give me design id 1 had when document loading.

but if click on "print design" button added see weather globalvars.selecteddesignid has correct value @ time fileupload() calling, give me current correct design id.

so how reload document.ready or pass globalvars.selecteddesignid updated value?

need badly...

basically users select design,

so means (i guessing) clickdesignitem .. function called first, globalvars defined , calling fileupload function after globalvars should...

but here, calling fileupload inside document.ready().that means fileupload called document gets ready globalvars might not set till then....


Comments