On Tuesday, February 4, 2014 3:36:12 PM UTC+1, 项楠 wrote:
OK, my situation seems similar to SO but much simpler. As we know, in a SO question detail page we can post a comment to this quesion, or to one of its answers, we can also post an answer to this question. All will be done in the same page, and if you just post comments, it is not required to reload the entire page to update the comments -- this is just what I don't know how to do.
Currently, I only know how to handle one form's POST data in a page -- handle answer form's POST data.
I know solutions have something to do with jquery. But it is hard for me to find a solution for my situation, and I am really tired after searching for a long time. Maybe for you it is just a very simple thing. Thanks.
Well, you don't need jQuery at all, what you want to do is called Ajax, but jQuery makes it a little easier.
So you have a page with multiple forms on it. You simply give those forms different action urls that point to different views and intercept the form submission with JavaScript. When you intercept the submission you send an Ajax request to the form's view instead, and do something with the returned data.
https://en.wikipedia.org/wiki/Ajax_(programming)
You might want to look into one of the REST packages for Django.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9856a2a7-97be-41a5-af6e-01fa7943fe2e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment