Hi Shawn, Thanks so much for your reply. Here is an example. I have a following dictionary in Python
employees = { "accounting" : [ // accounting is an array in employees. { "firstName" : "John", // First element "lastName" : "Doe", "age" : 18 }, { "firstName" : "Mary", // Second Element "lastName" : "Smith", "age" : 22 } ], // End "accounting" array. "sales" : [ // Sales is another array in employees. { "firstName" : "Sally", // First Element "lastName" : "Green", "age" : 21 }, { "firstName" : "Jim", // Second Element "lastName" : "Galley", "age" : 46 } ] // End "sales" Array. } // End Employees Now I want to pass it to a javaScript function (Ajax) in template. Then in the javaScript function I need to retrieve the dictionary content and save to a javaScript array. What's the syntax to pass this dictionary from view to the function in template? Any more help? Thanks so much. On Dec 11, 5:49 pm, Shawn Milochik <sh...@milochik.com> wrote: > What kind of object are you trying to send? JSON pretty much looks identical > to a Python dictionary, so if your object is a Python dictionary, list, or > tuple you'll have no problem -- just convert the Python object using > simplejson.dumps(). If this doesn't help much, please provide more detail > about the object you want to send and what you want to do with it in > JavaScript. > > In general, though, you'll need to serialize the object somehow so that > JavaScript can make use of it. I think simplejson will end up being part of > your solution, regardless of what you do. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.