-2

I made a form in html that makes login request to this website: https://kintai.jinjer.biz/sign_in Here is my html code:

<form  method="post" class= "login-form" action="https://kintai.jinjer.biz/v1/sign_in">

<input class="login-input--text jcompanycode" id="company_code" name="company_code" type="hidden" value="1234" /> 
<input class="jemail login-input--text" name="email" type="hidden" value="1234" /> 
<input class="jpassword login-input--text" name="password" placeholder="パスワード" type="hidden" value="1234" />
 <input type="submit" value= "submit" id= "submit" /> 
</form>

I wrote a javascript code to prevent redirect on submission of form.

<script>

 $(document).ready(function(){
 $('.login-form').submit(function(e){
    e.preventDefault();
   });
});

I want to prevent redirect on form submission. However, when i add the javascript, the post request doesn't work. Any ideas to send form data to server while remaining on current html page? Note: please don't tell me to use ajax or jquery to make the login request. I tried making post request using ajx/jquery a lot of times but it doesn't work. Perhaps due to same origin policy I presume.

  • possible duplicate of [https://stackoverflow.com/questions/5614099/jquery-preventdefault-not-working](https://stackoverflow.com/questions/5614099/jquery-preventdefault-not-working) – Luke-zhang-04 Apr 30 '20 at 03:26

1 Answers1

-2

HTML form redirect page is its feature.
If you want to avoid, please try to using formdata with ajax.

MDN FromData

MDN Fetch with FormData

LianSheng
  • 448
  • 5
  • 17