How do I set a variable in a function using Javascript or jQuery
I need to move the data out of HTML code and load it on demand.

I need to do something like this:

    function processData( data )
    {
       if ( data.length===0 )
       {         
          data = get data from server using Ajax
       }
       else go do stuff with data ;
    } 

    storeData = [] ;
    processData( storeData ) ; // first time storeData doesn't contain any data
    processData( storeData ) ; // now storeData contains data

I can't figure out how to stuff the data from within the function. Is there a way of accomplishing this?
    
How do I set a variable in a function using Javascript or jQuery
===

I need to move the data out of HTML code and load it on demand.

I need to do something like this:

    function processData( data )
    {
       if ( data.length===0 )
       {         
          data = get data from server using Ajax
       }
       else go do stuff with data ;
    } 

    storeData = [] ;
    processData( storeData ) ; // first time storeData doesn't contain any data
    processData( storeData ) ; // now storeData contains data

I can't figure out how to stuff the data from within the function. Is there a way of accomplishing this?
    