On Wed, Jun 16, 2010 at 1:17 PM, Alex <alexle...@googlemail.com> wrote: > Hi, > > Please can anyone help with an app architecture problem I am having? > (I am quite new to Django) > > I have an app which which serves up XHR requests (via YUI3 io > uitility) to urlpatterns. The views make HttpResponses using > render_to_response like so: > > return render_to_response("registration/register.html", { > 'form': form, > }, context_instance=RequestContext(request)) > > That is all fine: The html content is rendered in the relevant div > (using a YUI3 io's success callback) . > > But the problem I have - and I may be thinking about this in the wrong > way - is that I also want to pick out some variables from the response > to use in my js success callback. If I wasn't using django templating > this could be straightforwardly achieved with a JSON response parsed > client side. So my difficulty is that I want both a rendered template > response and some JSON response in the same callback... I have thought > about 'enriching' the render_to_response context with these additional > variables, inserting them in hidden html fields and then querying the > dom for their values - but that feels awkward and also means the > response has to be added to the dom before the js can act on their > values. > > This seems like a familiar nut that must be well documented > somewhere... :) any help, pointers very appreciated. > > Thanks > Alex >
The prototype framework allows you to place (small amounts) of JSON into the response header 'X-JSON', which it then evaluates, and stores in transport.headerJSON. If you are using prototype, that could be a solution, or implement your own version of that. Cheers Tom -- 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.