Update D3.md

master
Matt Huntington 8 years ago committed by GitHub
parent bfd259f39d
commit 7037e248e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

47
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 Named based off of what kind of data they accept
```javascript ```javascript
d3.json('path', function(error, data){}); d3.json('path').then(function(data){});
d3.csv('path', function(error, data){}); d3.csv('path').then(function(data){});
d3.tsv('path', function(error, data){}); d3.tsv('path').then(function(data){});
d3.xml('path', function(error, data){}); d3.xml('path').then(function(data){});
d3.html('path', function(error, data){}); d3.html('path').then(function(data){});
d3.text('path', function(error, data){}); d3.text('path').then(function(data){});
//make a post //make a post
d3.request('/runs') //make a request to the server d3.json('/runs', {
.header("Content-Type", "application/json") //tell the server we're sending JSON data method:'POST',
.post( headers:{
//must turn data object into string 'Content-type': 'application/json; charset=UTF-8'
JSON.stringify(runObject), },
function(){ //callback body:JSON.stringify(runObject)
}).then(function(data){});
}
);
//send delete //send delete
d3.request('/runs/'+d.id) d3.json('/runs/'+d.id, {
.header("Content-Type", "application/json") //we're sending data method:'DELETE',
.send('DELETE', function(){}); //send a DELETE request headers:{
'Content-type': 'application/json; charset=UTF-8'
}
}).then(function(data){});
//send update //send update
d3.request('/runs/'+d.id) d3.json('/runs/'+d.id, {
.header("Content-Type","application/json") //we're sending JSON method:'PUT',
.send('PUT', JSON.stringify(d), function(){});//pass alterted 'd' object to API headers:{
'Content-type': 'application/json; charset=UTF-8'
},
body:JSON.stringify(runObject)
}).then(function(data){});
``` ```
## Data binding ## Data binding

Loading…
Cancel
Save