Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 33 lines (32 sloc) 1.254 kb
5e71148 @Almad Add classes so bad selector engines are worky
Almad authored
1 <section name="javascript" class="javascript">
b62198c @zdne 'In' (input) renamed 'to' Request
zdne authored
2 <p class="ioDesc">Request</p>
3637277 @kuba-kubula PRE with CODE element with class language
kuba-kubula authored
3 <pre class="incoming"><code class="language-javascript">var xhr = new XMLHttpRequest();
4 xhr.open("<%= @method.toUpperCase() %>", "<%= @apiUrl %><%= @url %>");
5 <% for header, value of @headers: %>
6 xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
7 <% end %>
8 xhr.onreadystatechange = function () {
9 if (this.readyState == 4) {
10 alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
11 }
12 };
13 xhr.send(<%= @helpers.escape @body.join("\n") %>);</code></pre>
14 <pre class="jsRunCode" style="display: none">
15 var xhr = new XMLHttpRequest();
16 xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
17 <% for header, value of @headers: %>
18 xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
19 <% end %>
20 xhr.onreadystatechange = function () {
21 if (this.readyState == 4) {
22 if (typeof cb !== "undefined") {
23 cb(this);
24 }
25 else {
26 alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
27 }
28 }
29 };
30 xhr.send(<%= @helpers.escape @body.join("\n") %>);
31 </pre>
57b2994 @gr2m added javascript template
gr2m authored
32 </section>
Something went wrong with that request. Please try again.