Friends of Symfony JS Routing Bundle was made exactly for your needs
var url = Routing.generate('some_route_to_expose', { foo: 'bar' });
// url is http://somehost.com/app_dev.php/my_route
The bundle also lets you dump, compile and minify the resulting javascript. Its great!