It shouldnt break.
You should do this:

Create a route to reach your module/action (/apps/$app/config/routing.yml,
check doc).
Then in a template, write something like:

<script type="text/javascript">
window.myactionurl = "<?php echo url_for('@my_route')?>";

alert(window.myactionurl);
$.post(window.myactionurl, null, function(data){//...});
</script>

This is a stupid example (about the window.myactionurl, store this somewhere
else).


Before Printing, Think about Your Environmental Responsibility!
Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!


On Sat, Aug 7, 2010 at 12:25 PM, Phennim <phen...@gmail.com> wrote:

> Get the url from the DOM using js.
>
> $('a.do-ajax').click(function(){
>  var url = $(this).attr('href');
>
>  $.post(url, function(data){
>    //do stuff
>  });
> });
>
>
> On Aug 7, 11:11 am, "Sebastien Armand [Pink]" <khe...@gmail.com>
> wrote:
> > Hello everyone,
> >
> > I was wondering how to get an environment independent url in javascript
> > files. My js needs to connect to the server and get some JSON data and
> > update a form on certain actions. But putting that actions url in the js
> > directly breaks everything when you change environment...
> >
> > I might be missing something here but don't see the light of how to do
> it,
> > any insight welcome ;-)
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to