@nicolette.stoltenberg Используйте preventDefault() метод в jQuery чтобы убрать перезагрузку страницы при нажатии или отправки формы, ниже пример кода как это работает:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<html> <head> <meta charset="utf-8"/> <script src="https://code.jquery.com/jquery-2.2.4.js"></script> </head> <body> <form id="login" method="post"> <label for="username">Имя пользователя: </label> <input id="username" type="text" name="username" placeholder="Username" maxlength="20" value=""/> <label for="password">Пароль: </label> <input id="password" type="password" name="password" placeholder="Password" maxlength="14" value=""/> <button type="submit">Отправить</button> </form> </body> <script> $('#login').on('submit', function (e) { // Ваш код console.log("перезагрузка страницы убрана") e.preventDefault(); }); </script> </html> |