jquery global variables usable everywhere
<p>I am starting to doubt that jquery is easy to use and flexible.
I have this:</p>

<pre><code>var prodata=[];
var request = $.get("proDB.txt", function(data) {
    var lines=data.split(/\n/);
    var numberofmodels=lines.length-2;
    //var prodata=[];
    var i;
    prodata.push(0);
    var fieldnames=lines[0].split(/\t/);
    for (i = 1; i &lt; lines.length-1; ++i) {
        var fields=lines[i].split(/\t/);
        prodata.push(i);            
        var j;
        prodata[i]={};
        for (j = 0; j &lt; fields.length; ++j) {
            //prodata[i][fieldnames[j]]=fields[j];
            var str=fieldnames[j];
            prodata[i][str]=fields[j];

        }
    }

    //FILL THE DROPDOWN LIST
    var options = '';
    for (i = 1; i &lt; lines.length-1; ++i) {
        if (prodata[i]['name'].indexOf("elly") &gt;= 0) {
            var iselected = i;
        }
        options += '&lt;option label="bla" value="' + prodata[i]['id'] + '"&gt;' + prodata[i]['name']+', '+prodata[i]['brand']+', '+prodata[i]['model']+'&lt;/option&gt;';
    }
    $("#userchosenpromodel").html(options);
    //SELECT DEFAULT OPTION
    $('#userchosenpromodel option[value="' + prodata[iselected]['id'] + '"]').attr("selected", "selected");
}, 'text'); //$.get
</code></pre>

<p>I would like to use <code>proId</code>, lower in my code, after it's been defined like that:</p>

<pre><code>//SUBMIT FORM
$('#submitbutton').click(function(e) {
    e.preventDefault(); 
    request.done(function(){
        proId=$('#userchosenpromodel option[selected="selected"]').val();
        proId=parseInt(proId);
        computeUserDimensions(prodata[proId]);
    });
});
    console.log(proId);
</code></pre>

<p>How to?</p>

<p>Same problem for <code>prodata</code>...I have <code>request.done</code> that I can't get rid of</p>

<p>Thanks</p>
