blob: 34bbc8cf70689575a47f33917e9f2117b5984ead (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
</head>
<body>
<form id="myForm" name="myForm">
<div>
<label for="login">login:</label>
<input type="text" id="login" name="login">
</div>
<div>
<label for="password">password:</label>
<input type="text"id="password"name="password">
</div>
<input type="submit"value="Submit!">
</form>
<script>
$(document).ready(function () {
$('#myForm').submit(function (event) {
event.preventDefault();//collect the form data using Id Selector for whatever data you need to send to server
let login=$('#login').val();
let password=$('#password').val();
$.post('logintry',
{"login": login,"password": password},
(data) => {
console.log(data);
if(data.status === 'success'){
//pseudo code
//Make sure error message is not displayed
//Re-direct to contacts page,
window.location.href='contacts';}
else{
//Display error message
}});});});</script>
</html>
|