Skip to content

Commit

Permalink
Updated Dan's version to reflect changes in node.js to bring it in li…
Browse files Browse the repository at this point in the history
…ne with CommonJS.
  • Loading branch information
Alex Robinson authored and Dan DeFelippi committed Jun 16, 2010
1 parent 93a54c5 commit c699824
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README
Expand Up @@ -2,11 +2,11 @@ Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.

This can be used with JS designed for browsers to improve reuse of code and allow the use of existing libraries.

Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs.
Usage: var XMLHttpRequest = require("XMLHttpRequest").XMLHttpRequest and use per W3C specs.

*TODO*

SSL support
Basic authentication
Additional unit tests
Possibly move from http to tcp for better flexability
Possibly move from http to tcp for more flexibility
2 changes: 1 addition & 1 deletion XMLHttpRequest.js
Expand Up @@ -16,7 +16,7 @@ exports.XMLHttpRequest = function() {
* Private variables
*/
var self = this;
var http = require('/http.js');
var http = require('http');

// Holds http.js objects
var client;
Expand Down
10 changes: 5 additions & 5 deletions demo.js
@@ -1,14 +1,14 @@
include("/utils.js");
include("XMLHttpRequest.js");
var sys = require('sys');
var XMLHttpRequest = require("./XMLHttpRequest").XMLHttpRequest;

var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function() {
puts("State: " + this.readyState);
sys.puts("State: " + this.readyState);

if (this.readyState == 4) {
puts("Complete.\nBody length: " + this.responseText.length);
puts("Body:\n" + this.responseText);
sys.puts("Complete.\nBody length: " + this.responseText.length);
sys.puts("Body:\n" + this.responseText);
}
};

Expand Down

0 comments on commit c699824

Please sign in to comment.