Using the code listed (return render_to_response....) is going to
cause a page refresh (a synchronous operation), if you are trying to
use ajax (asynchronously), you should stick the html from the form and
the entry into a json or xml object to return to your javascript
callback.  This is assuming that you are asynchronously submitting the
form.  I am building an app right now that relies heavily on async
connectivity (I am using portions of the YUI in the browser) and I
use

form_object = render_to_response(template, 'form': form)

to format my forms normally, but stick the form_object._container into
a response_dict before calling simplejson.dumps(response_dict) on it
to format it into json for my callback.

-rfd


On Sep 11, 4:19 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 11, 3:11 pm, garonne <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I 've started playing with Django which seems very well for what i
> > need but i still can figure out how to implement a very simple ajax
> > example:
>
> > I would like to have a form with a  textarea and after pressing the
> > button, i wish to see the form and the text print below. For some
> > reason i'm not able to keep both on the same page. I put my code
> > below.
>
> If you want both the form and the value of Entry to show at the same
> time, you need to pass them both into the context. So this should
> work...
>
> def index(request):
>     Entry = "No Entry"
>     if request.method == 'POST':
>         form = Form(request.POST)
>         if  form['Entry'].data:
>             Entry  = form['Entry'].data
>     else:
>         form = Form()
>     return render_to_response('index.html', {'form': form,
> 'Entry':Entry})
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to