jQuery ajax request error: ajax error:{"readyState":0,"status":0,"statusText":"error"}

created at 06-04-2022 views: 25

error

ajax error:{"readyState":0,"status":0,"statusText":"error"}

solution

Change the type field of button from submit to button, because submit will submit the form by default, and the click event is bound to ajax, so the ajax request is canceled.

<form id="login-form" role="form" class="form">
    ...
    //Change the type of button from submit to button
  <button id="login-btn" type="button" class="btn btn-success login-btn">
      Submit registration
  </button>
</form>
created at:06-04-2022
edited at: 06-04-2022: