Thanks guys, and Udi for the example. That shed some light on what I
needed to do and it worked great!



On Mar 24, 7:19 pm, Udi <[EMAIL PROTECTED]> wrote:
> I've been using this more or less this approach:
>
> PYTHON:
>
> t = loader.get_template('posts.html')
> html = t.render(Context({ 'tweets' : tweets }))
>
> data = { 'html': html, 'tweet_count': len(tweets) }
> json = simplejson.dumps(data)
>
> return HttpResponse(json, mimetype = 'application/javascript')
>
> JAVASCRIPT, in your xhr callback fn:
>
> var jsonObject = eval('(' + jsonString + ')');
> var html = jsonObject.html; //now you can inject this into a
> container
> var listLength = jsonObject.tweet_count; //you can use the extra meta-
> data too
>
> Hope that helps,
> Udi
>
> On Mar 22, 3:43 pm, truebosko <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
>
> > I am trying to switch my function to return a JSON request. Right now,
> > it simply returns an HTML template, here's the basic code:
>
> > return render_to_response('posts.html',
> >                                 { 'tweets' : tweets })
>
> > Simple, obviously. Tweets is just a list, and posts.html goes through
> > them (Using a for loop) and out pops my template, with 1 .. * tweets
> > listed.
>
> > But, I want to change it around, I want to do something like the
> > following:
>
> > return:
> > - posts.html formatted like it currently is
> > - Several variables, not within the HTML
>
> > I looked around and I simply can't figure out how to do it. Any
> > suggestions?
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to