[jQuery] Passing variables to a dynamically loaded script

[jQuery] Passing variables to a dynamically loaded script


I am writing a page where I need to load different scripts based on
what the user is allowed to do. I started by using
$.getScript("test.js"), which worked fine until I realized that I need
a variable from the original page within the script I called.
What I have ended up doing (and haven't tested beyond firefox2) is
using a regular $.get and doing an eval() in the callback. This seems
to allow me to use the variable I need within test.js, but it really
seems that there should be a better way of doing this. Maybe it is
just my dislike for eval() that makes me not like what I am using
now. Any suggestions?
//a dumbed down version of what I'm doing
var pageId = 1234;
$.get( "test.js", function(data){
eval(data);
});