This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevelopment_javascript_Http.html
116 lines (82 loc) · 2.75 KB
/
development_javascript_Http.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobile Widgets</title>
<link rel="stylesheet" href="style/style.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/StructureElts.js"></script>
<script type="text/javascript" src="js/Structure.js"></script>
<script type="text/javascript" src="js/DocElements.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
idCurrentPage = "development_javascript_Http";
beginPage();
//-->
</script>
<h1 class="title">HTTP Javascript library</h1>
<script type="text/javascript">
<!--
addIndex();
//-->
</script>
<script type="text/javascript">addTitle("Description", 1);</script>
<p>
Asynchronous HTTP(S) request API.
</p>
<br/>
<script type="text/javascript">addTitle("Methods", 1);</script>
<p>
<b>void get (String url, Function callback, String encoding)</b>:<br/>
Send an HTTP GET request using url, the callback is called on response. Encoding
is optional (Default: UTF-8).
</p>
<p>
<b>void post (String url, String postData, Function callback, String encoding)</b>:<br/>
Send an HTTP POST request using url and the postData, the callback is called on
response. Encoding is optional (Default: UTF-8).
</p>
<br/>
<script type="text/javascript">addTitle("Examples", 1);</script>
<h2>HTTP GET example</h2>
<textarea wrap="off" readonly="readonly" rows="10" cols="80">
function test () {
Http.get ('http://google.com/', onGoogleLoad);
}
function onGoogleLoad (url, responseCode, responseData, now) {
Browser.print ('HTTP GET url: '+url);
Browser.print ('HTTP GET responseCode: '+responseCode);
Browser.print ('HTTP GET responseData: '+responseData);
Browser.print ('Time in scene is : '+now);
}
</textarea>
<br/>
<h2>HTTP POST example</h2>
<textarea wrap="off" readonly="readonly" rows="10" cols="80">
function test () {
Http.post ('http://google.com/', 'this is not a correct POST data for Google', onGoogleLoad);
}
function onGoogleLoad (url, responseCode, responseData, now) {
Browser.print ('HTTP POST url: '+url);
Browser.print ('HTTP POST responseCode: '+responseCode);
Browser.print ('HTTP POST responseData: '+responseData);
Browser.print ('Time in scene is : '+now);
}
</textarea>
<br/>
<script type="text/javascript">
<!--
addBackPageNavigator('widgets_development_javascript_ref', '');
//-->
</script>
<script type="text/javascript">
<!--
endPage();
//-->
</script>
</body>
</html>