forked from jameslnewell/xhr-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.html
38 lines (30 loc) · 829 Bytes
/
jquery.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>jQuery Example — xhr-mock</title>
</head>
<body>
<h1>xhr-mock</h1>
<h2>jQuery Example</h2>
<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script src="../build/build.js"></script>
<script>
var mock = require('xhr-mock');
mock.setup();
mock.get('http://google.com/', function(req, res) {
return res
.status(200)
.body('<h1>Google</h1>')
;
});
// ---------
$.get('http://google.com/', function(data, textStatus, jqXHR) {
console.log('loaded', data);
}).fail(function() {
console.log('ERROR', arguments);
});
// ---------
</script>
</body>
</html>