Returning form errors for AJAX request in Django
Posted
by mridang
on Stack Overflow
See other posts from Stack Overflow
or by mridang
Published on 2010-04-12T19:23:55Z
Indexed on
2010/04/12
19:43 UTC
Read the original article
Hit count: 600
Hi Guys,
I've been finding my way around Django and jQuery. I've built a basic form in Django. On clicking submit, I'm using jQuey to make an AJAX request to the sever to post my data. This bit seems to work fine and I've managed to save the data. Django returns a ValidatioError when a form is invalid. Could anyone tell me how to return this set of error messages as a response to my AJAX request so i can easily iterate through it using JS and do whatever?
I found this snippet. Looking at the JS bit (processJson) you'll see that he seems to get the error messages by extracting them from the response HTML. It seems kinda kludgy to me. Is this a best way to go about it?
My apologies for any vagueness.
Thanks in advance.
© Stack Overflow or respective owner