Permalink
Browse files

Fix alert typo & add ugly hack for in-browser code execution

  • Loading branch information...
1 parent a27695c commit 7d59389da37688f815bf53a30a3e3018844fb971 @Almad Almad committed Jul 24, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 javascript.html
View
15 javascript.html
@@ -8,7 +8,20 @@
<% end %>
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
- alert('Status: '+this.status+\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
+ alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
+ }
+ };
+ xhr.send(<%= @helpers.escape @body.join('') %>);
+ </pre>
+ <pre class="jsRunCode" style="display: none">
+ var xhr = new XMLHttpRequest();
+ xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
+ <% for header, value of @headers: %>
+ xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
+ <% end %>
+ xhr.onreadystatechange = function () {
+ if (this.readyState == 4) {
+ alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
}
};
xhr.send(<%= @helpers.escape @body.join('') %>);

0 comments on commit 7d59389

Please sign in to comment.