On Sun, Feb 22, 2009 at 7:07 PM, CALdan <dannyboy...@gmail.com> wrote:
> > Hi! > > I want to pass data from Django to populate javascript variables > dynamically after page load. I'm using ajax.updater to call url's > from Django to update div's within my pages but in some instances it > would be of great use to pass just a variable instead of HTML code. > > Is there a way of doing this? > > Thanks! > > > > Sure, the usual way to do this is have you Django view return a JSON(or XML, or whatever format) response and then have your javascript library of choice parse this response into some datastructure you can use. For the Django view end you can use standard python libraries such as simplejson to create the response(Django includes a recent version of this), and in JavaScript you can use your favorite library to take the JSON and create a JS object. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---