diff --git a/D3.md b/D3.md index f03dd0d..4e4d50f 100644 --- a/D3.md +++ b/D3.md @@ -60,33 +60,38 @@ d3.selectAll('div').text('hi'); //set the content of the selection to the exact Named based off of what kind of data they accept ```javascript -d3.json('path', function(error, data){}); -d3.csv('path', function(error, data){}); -d3.tsv('path', function(error, data){}); -d3.xml('path', function(error, data){}); -d3.html('path', function(error, data){}); -d3.text('path', function(error, data){}); +d3.json('path').then(function(data){}); +d3.csv('path').then(function(data){}); +d3.tsv('path').then(function(data){}); +d3.xml('path').then(function(data){}); +d3.html('path').then(function(data){}); +d3.text('path').then(function(data){}); //make a post -d3.request('/runs') //make a request to the server - .header("Content-Type", "application/json") //tell the server we're sending JSON data - .post( - //must turn data object into string - JSON.stringify(runObject), - function(){ //callback - - } - ); +d3.json('/runs', { + method:'POST', + headers:{ + 'Content-type': 'application/json; charset=UTF-8' + }, + body:JSON.stringify(runObject) +}).then(function(data){}); //send delete -d3.request('/runs/'+d.id) - .header("Content-Type", "application/json") //we're sending data - .send('DELETE', function(){}); //send a DELETE request +d3.json('/runs/'+d.id, { + method:'DELETE', + headers:{ + 'Content-type': 'application/json; charset=UTF-8' + } +}).then(function(data){}); //send update -d3.request('/runs/'+d.id) - .header("Content-Type","application/json") //we're sending JSON - .send('PUT', JSON.stringify(d), function(){});//pass alterted 'd' object to API +d3.json('/runs/'+d.id, { + method:'PUT', + headers:{ + 'Content-type': 'application/json; charset=UTF-8' + }, + body:JSON.stringify(runObject) +}).then(function(data){}); ``` ## Data binding