Built motion from commit 7e022ab.|2.0.14
[motion2.git] / demo / agents / index.html
1 <!DOCTYPE html>
2 <html>
3
4 <head>
5     <meta charset="utf-8">
6     <title>Create agents</title>
7     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
8     <script src="ajax.js"></script>
9 </head>
10
11 <body>
12     <input type="button" id="agents" value="Create Agents">
13     <script type="text/javascript">
14         $(document).ready(function() {
15             $("#agents").click(function() {
16                 var a = new Ajax();
17                 a.request('GET', 'http://192.168.2.140/api/users', true, {
18                         jsonp: true,
19                         success: function(res) {
20                             console.log(res);
21                         },
22                         error: function(err) {
23                             console.log(err);
24                         }
25                     })
26                     // var xhr = new XMLHttpRequest();
27                     // xhr.open("GET", "http://192.168.2.140/api/users", true);
28                     // xhr.withCredentials = true;
29                     // xhr.setRequestHeader("Authorization", 'Basic ' + btoa('admin:password'));
30                     // xhr.onload = function () {
31                     //     console.log(xhr.responseText);
32                     // };
33                     // xhr.send();
34                     // var USERNAME = 'admin';
35                     // var PASSWORD = 'password';
36                     //
37                     // for (var i = 0; i < 10; i++) {
38                     //   $.ajax({
39                     //     type: "POST",
40                     //     url: "http://192.168.2.140/api/users",
41                     //     dataType: 'jsonp',
42                     //     async: false,
43                     //     headers: {
44                     //       "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
45                     //     },
46                     //     data: {
47                     //       role: 'agent',
48                     //       name: 'agent' + i
49                     //     },
50                     //     success: function(res) {
51                     //       console.log(res)
52                     //     },
53                     //     error: function(err) {
54                     //       console.log(err);
55                     //     }
56                     //   });
57                     // }
58             });
59         });
60     </script>
61 </body>
62
63 </html>