-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample.html
54 lines (48 loc) · 1.94 KB
/
example.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
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Offline Requests</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<!-- Offline-js -->
<link rel="stylesheet" href="http://github.hubspot.com/offline/themes/offline-theme-chrome.css">
<link rel="stylesheet" href="http://github.hubspot.com/offline/themes/offline-language-english.css">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h3>Handling Failed Requests</h3>
<form id="form1" class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
Name:
<input type="text" name="name" value="" class="form-control">
</div>
</div>
<div class="form-group">
<button type="submit" name="button" class="btn">Send</button>
</div>
</form>
</div>
</div>
<script src="/lib/handle-requests.min.js"></script>
<script type="text/javascript">
var req = new Request()
document.getElementById('form1').addEventListener('submit', function (e) {
e.preventDefault()
var inputs = [].slice.call(e.target.getElementsByTagName('input'))
var data = {}
inputs.forEach(function (input) {
data[input.name] = input.value
})
req.send('/example.html', data).then(function (res) {
console.log(res.data)
})
})
</script>
</body>
</html>