Saturday, May 1, 2010

Re: Defining constants like APP for use in javascript

almost^^

my baseurl always has a slash at the end
so it might be
$.getJSON(baseurl + "path/myson.json", function(json) ...

On 1 Mai, 16:35, fly2279 <kennethf...@gmail.com> wrote:
> Thank you!
>
> On May 1, 9:06 am, AD7six <andydawso...@gmail.com> wrote:
>
>
>
> > On May 1, 3:22 pm, fly2279 <kennethf...@gmail.com> wrote:
>
> > > Andy, thanks for the quick response. I guess what I'm trying to do is
> > > include an absolute path that is relative to the app's path. For
> > > example:
>
> > > $.getJSON("/path/myson.json", function(json) {
> > >   // code here
>
> > > });
>
> > > What if the app is installed in a subdirectory? Then I'd have to put "/
> > > subdir/path/myson.json". How do I keep the code flexible without
> > > having to change it for each install?
>
> > If you included the js file  I linked to (and were using jquery) it'd
> > be:
>
> > $.getJSON($.url("/path/myson.json"), function(json) {
> >    // code here
> >  });
>
> > If you used euromarks example it'd be:
>
> > // baseurl is a global var set in your layout in a script tag
> > $.getJSON(baseurl + "/path/myson.json", function(json) {
> >    // code here
> >  });
>
> > They both achieve the same thing. Do whatever works and you're most
> > comfortable with.
>
> > hth,
>
> > AD
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

No comments: