1👍
There are multiple issues that could be causing this behavior:
- You are submitting your form, therefore reloading the page. The
ajax1()
function should returnfalse
to prevent the browser from automaticly sending the form. - The url that is used in
xhr.open()
is not the same as the url defined inurls.py
- I’m not sure what causes the broken pipe error. It might be the mimetype.
application/javascript
is used for sending actual Javascript code to the browser. The mimetype that you need for sending text (like with AJAX) istext/plain
. In your case there is no need for defining the mimetype at all.
Source:stackexchange.com