-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlhttpRequest.html
More file actions
175 lines (158 loc) · 5.53 KB
/
xmlhttpRequest.html
File metadata and controls
175 lines (158 loc) · 5.53 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AJAX Introduction</title>
<link rel="stylesheet" href="home.css" />
</head>
<body>
<div class="sidebar">
<a class="content intro" href="/home.html"> Introduction</a>
<a
class="content XMLHTTPRequestObject"
href="/xmlhttpRequest.html"
style="background-color: rgb(56, 132, 56);"
>XML HTTP Request Object</a
>
<a class="content XMLHTTPRequestObject" href="/AjaxServerResponse.html">AJAX Server Response</a>
<a class="content" href="/AjaxXML.html">AJAX XML</a>
<a class="content" href="/AjaxDatabase.html">AJAX Database</a>
</div>
<div class="maincontent">
<h1 style="padding: 10px">AJAX Request Object</h1>
<div class="buttons">
<a href="/home.html" class="button previous" style="cursor: pointer;">Previous</a>
<a href="/AjaxServerResponse.html" style="cursor: pointer;" class="button next">Next</a>
</div>
<hr />
<div class="second-intro">
<h1>The XMLHttpRequest Object</h1>
<h4>All modern browsers support the XMLHttpRequest object.</h4>
<h4>
The XMLHttpRequest object can be used to exchange data with a server
behind the scenes. This means that it is possible to update parts of a
web page, without reloading the whole page.
</h4>
</div>
<hr />
<div class="second-create">
<h2>Create an XMLHttpRequest Object</h2>
<div class="code-container">
<h3>syntax for creating xmlhttpRequest object</h3>
<pre style="background-color: black; padding: 10px">
variable = new XMLHttpRequest(); </pre
>
</div>
</div>
<hr />
<div class="accesscrossdomain">
<h1>Access Across Domain</h1>
<p>
For security reasons, modern browsers do not allow access across
domains.
</p>
<p>
This means that both the web page and the XML file it tries to load,
must be located on the same server.
</p>
<p>
The examples on W3Schools all open XML files located on the W3Schools
domain.
</p>
<p>
If you want to use the example above on one of your own web pages, the
XML files you load must be located on your own server.
</p>
</div>
<hr>
<div class="requestObjectMethod">
<h2>XMLHttpRequest Object Methods</h2>
<table style="width: 100%;">
<tr>
<th>Method</th>
<th>Description</th>
</tr>
<tr>
<td>new XMLHttpRequest()</td>
<td> Creates a new XMLHttpRequest object </td>
</tr>
<tr>
<td>abort()</td>
<td>Cancels the current request </td>
</tr>
<tr>
<td>getAllResponseHeaders()</td>
<td> Returns header information </td>
</tr>
<tr>
<td>getResponseHeader()</td>
<td> Returns specific header information </td>
</tr>
<tr>
<td>open(method,url,async,user,psw)</td>
<td> Specifies the request</td>
</tr>
<tr>
<td>send()</td>
<td> Sends the request to the server <br>
Used for GET requests</td>
</tr>
<tr>
<td>send(string)</td>
<td>Sends the request to the server.<br>
Used for POST requests</td>
</tr>
</table>
</div>
<hr>
<div class="requestObjectMethod">
<h2>XMLHttpRequest Object Methods</h2>
<table style="width: 100%;">
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td>readyState</td>
<td> Holds the status of the XMLHttpRequest.<br>
0: request not initialized<br>
1: server connection established<br>
2: request received<br>
3: processing request<br>
4: request finished and response is ready </td>
</tr>
<tr>
<td>onreadystatechange</td>
<td>Defines a function to be called when the readyState property changes </td>
</tr>
<tr>
<td>responseText</td>
<td> Returns the response data as a string </td>
</tr>
<tr>
<td>responseXML</td>
<td> Returns the response data as XML data </td>
</tr>
<tr>
<td>status</td>
<td> Returns the status-number of a request <br>
200: "OK" <br>
403: "Forbidden" <br>
404: "Not Found" <br>
For a complete list go to the Http Messages Reference</td>
</tr>
<tr>
<td>statusText</td>
<td> Returns the status-text (e.g. "OK" or "Not Found")
</td>
</tr>
</table>
</div>
<div class="buttons">
<a href="/home.html" class="button previous" style="cursor: pointer;">Previous</a>
<a href="/AjaxServerResponse.html" class="button next" style="cursor: pointer;">Next</a>
</div>
</div>
</body>
</html>