On Aug 21, 2:15 pm, Christopher <[EMAIL PROTECTED]> wrote: > 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?
i just wrote a long write-up for you on how to do this but Firefox crashed and i lost it... so here's a summary. You can't send vars directly to JS, unfortunately, but one way to simulate this is to use a PHP (or other server-side) filter: $.get('myScript.php', {foo:'bar'}); // this will return JS code, not PHP code myScript.js: ... foo = REPLACEMENT_FOO; ... myScript.php: $txt = file_get_contents('myScript.js'); $txt = preg_replace( '/\bREPLACEMENT_FOO\b/', $_GET['foo'], $txt ); echo $txt; Obviously, you need to do error handling and checking $_GET['foo'] and such, but you get the general idea. If you need help understanding preg_replace(), i recommend googling for "perl compatible regular expressions", as there is TONS of information available on them out there. :)