-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.html
46 lines (34 loc) · 1007 Bytes
/
ajax.html
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
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Ajax Component Sample</title>
</head>
<body>
<form action="https://reqres.in/api/users?page=2x" data-onsuccess="on_success" data-before-send="before_send" data-after-send="after_send" data-complete="on_complete" data-error="on_error">
<button>submit</button>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/ajax-form.js"></script>
<script>
$(function(){
$('form').ajax_form();
});
function on_success(e){
console.log(e);
}
function before_send(){
alert('sending...');
}
function after_send(){
alert('after send function triggered, ajax request completed');
}
function on_complete(){
alert('ajax request completed');
}
function on_error(){
alert('Op\'s there\'s an error occured');
}
</script>
</body>
</html>