Your JS looks decidedly incorrect. You say the aim is to prevent the
form being submitted in certain scenarios, yet your form submit
handler neither returns true nor false. You return truthiness from
your anonymous AJAX handler, but that is not the same.
Secondly, your check to see whether to submit the form uses AJAX. The
first A is important there, the communication happens asynchronously.
This sequence of events occurs:
Form submit handler called
Form submit handler creates an AJAX request
AJAX request is submitted to the server
Form submit handler completes with no return value
Browser prepares to submit the form
Browser closes any open network connections the page has
Server attempts to write to closed socket, generating quoted exception
Browser submits form to server
You need to make your jquery AJAX call synchronous, and return
true/false from the appropriate location. "jquery synchronous ajax"
should give you all the information you need.
Cheers
Tom
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/django-users/-/7G1wG2673jQJ.
> To post to this group, send email to
django...@googlegroups.com.
> To unsubscribe from this group, send email to
>
django-users...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/django-users?hl=en.