Hi everyone,
I have a login form for which I want the client to send AJAX POST
request as below with error handling. In case of
validation/authentication errors, I don't the page to be reloaded or
refreshed to the url corresponding to POST request Handler
(/users/login/) with the JSON string received from
login view's response. I tried using
event.preventDefault()
as suggested by many answer on SO but could not make it work. Any clue
as to what is going wrong here? I don't think this to be a Django issue.
I know that the
onsubmit is triggerred because the window redirects to the POST handler URL
/users/login/ with the expected JSON string response(i.e. JsonResponse) -
{"error": ["Entered mobile number is not registered"]}
Please check this stackoverflow link for the code and complete details. Thanks.