Skip to content
Browse files

Got through the basics of the request functions. Hit d3.ns as well but

will probably loop back around.
  • Loading branch information...
1 parent 9974b4d commit 3712116c18d8c2847005660ec7bdc05711a0e97a @zmaril committed Jul 16, 2012
Showing with 6 additions and 0 deletions.
  1. +1 −0 src/core/html.js
  2. +1 −0 src/core/json.js
  3. +2 −0 src/core/ns.js
  4. +1 −0 src/core/text.js
  5. +1 −0 src/core/xml.js
View
1 src/core/html.js
@@ -1,3 +1,4 @@
+//A wrapper around d3.text that sets the MIME type to HTML and then handles the edge case of the responseText being empty.
d3.html = function(url, callback) {
d3.text(url, "text/html", function(text) {
if (text != null) { // Treat empty string as valid HTML.
View
1 src/core/json.js
@@ -1,3 +1,4 @@
+//A wrapper around d3.text that sets the MIME type to JSON and then parses the JSON before passing it to the callback.
d3.json = function(url, callback) {
d3.text(url, "application/json", function(text) {
callback(text ? JSON.parse(text) : null);
View
2 src/core/ns.js
@@ -1,3 +1,5 @@
+//Used for SVG namespacing. Mostly an internal method that is used before appending SVG elements to the page.
+//TODO: better explanation of what is going on.
var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
View
1 src/core/text.js
@@ -1,3 +1,4 @@
+//A wrapper around d3.xhr that passes back the responseText of the response to the callback.
d3.text = function(url, mime, callback) {
function ready(req) {
callback(req && req.responseText);
View
1 src/core/xml.js
@@ -1,3 +1,4 @@
+//A wrapper around d3.xhr that grabs the responseXML from the response and then calls the callback. Similiar to d3.text in terms of scope.
d3.xml = function(url, mime, callback) {
function ready(req) {
callback(req && req.responseXML);

0 comments on commit 3712116

Please sign in to comment.
Something went wrong with that request. Please try again.