Saturday, May 29, 2010

Re: passing variable values in javascript being served statically

Hi.
here is the code: http://pastebin.com/HtNq52aV

what i am trying to do::
get the visitor location from his IP address in {{latitude}} and
{{longitude}} ..... get my business location in
{{BUSINESS_LOCATION}} ..... then trace a route from visitor location
to my business location.


On May 25, 1:25 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On May 24, 8:24 pm,gvkalra<gvka...@gmail.com> wrote:
>
>
>
> > Hi.
> > I am trying to do something like this:
>
> > views.py
>
> > return render_to_response('abc.html',{'variable':value})
>
> > abc.html
>
> > <script>
> > dummy = {{variable}};
> > </script>
> > <script src = "xyz.js"/>
>
> > My problem:
> > I am not able to use dummy inside xyz.js ....... OR is there some
> > other way by which I can use {{variable}} inside xyz.js ??
>
> This is generally the right approach. What is the value of 'variable'
> though? If it's a string, you'll need to wrap it in quotes for the
> javascript to be valid. Also, the rule with Javascript is that
> variables defined outside of a function need to be defined with "var"
> to be global.
>
>   var dummy = "{{variable}}";
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

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

No comments:

Post a Comment