Retrieve settings with Javascript

Hello,

Is it possible to retrieve a theme/site setting from within a plugin using javascript?

Basically, I need to use get_theme_option('foo') and set it as a variable in a javascript document and am not sure how to achieve that.

Thanks -- Erin

I wouldn't call it "getting an option with Javascript," but you can easily pass an option into JavaScript code with PHP:

<script type="text/javascript">
var option = <?php js_escape(get_theme_option('foo')); ?>;
</script>

If you need the option inside a .js file, it's often easiest to make a function that takes the option as an argument, so the PHP view that's including the script can inject the option.