notes for ajax, delete, post, update

master
Matt Huntington 9 years ago
parent beda3ace8f
commit 9148e9ce13

21
D3.md

@ -60,6 +60,27 @@ d3.tsv('path', function(error, data){});
d3.xml('path', function(error, data){}); d3.xml('path', function(error, data){});
d3.html('path', function(error, data){}); d3.html('path', function(error, data){});
d3.text('path', function(error, data){}); d3.text('path', function(error, 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
}
);
//send delete
d3.request('/runs/'+d.id)
.header("Content-Type", "application/json") //we're sending data
.send('DELETE', function(){}); //send a DELETE request
//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
``` ```
## Data binding ## Data binding

Loading…
Cancel
Save