From 67095e6758cf28429f79b782dabcdd9e9e2e6322 Mon Sep 17 00:00:00 2001 From: Patrick Moulden Date: Thu, 28 Apr 2016 09:11:28 -0500 Subject: [PATCH 1/3] Update index.html --- public/index.html | 167 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 165 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 34ebddf4..236aca9d 100644 --- a/public/index.html +++ b/public/index.html @@ -8,15 +8,178 @@ - +
- + From d11af9e353f8c21153b8451e842c8e6539e81025 Mon Sep 17 00:00:00 2001 From: Patrick Moulden Date: Thu, 28 Apr 2016 09:15:48 -0500 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4862f5df..a53e2983 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) +A version of the React Tutorial (completed) without the jQuery dependency and using a promise factory for all AJAX requests + # React Tutorial This is the React comment box example from [the React tutorial](http://facebook.github.io/react/docs/tutorial.html). From 5cafa92a3e2a83b455e2c8b8c950a196fcb75503 Mon Sep 17 00:00:00 2001 From: Patrick Moulden Date: Thu, 28 Apr 2016 09:23:00 -0500 Subject: [PATCH 3/3] documentation Added documentation for promise factory --- public/index.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/index.html b/public/index.html index 236aca9d..de6713c5 100644 --- a/public/index.html +++ b/public/index.html @@ -18,13 +18,17 @@ // To get started with this tutorial running your own code, simply remove // the script tag loading scripts/example.js and start writing code here. var CommentBox = React.createClass({ + // promise factory to generate async HTTP requests. + // replaces functionality previously provided by jQuery ajax: function(method, url, exType, args) { console.log(args); var promise = new Promise(function(resolve,reject){ var uri = url; var client = new XMLHttpRequest(); client.open(method, uri); + // set expected data type client.responseType = exType; + // handle request payload for POST and PUT methods if (args && (method === 'POST' || method === 'PUT')) { var payload = ''; var argcount = 0; @@ -41,6 +45,7 @@ } else { client.send(); } + // handle HTTP response client.onload = function () { if (this.status >= 200 && this.status < 300) { // Performs the function "resolve" when this.status is equal to 2xx