I ran into the same problem of d3.xhr.post seemingly not sending any post data. Setting the content-type
header information to application/json
fixed it for me. Here is your updated example:
var rpcUrl = "http://localhost:3001/rpc/json";
var rpcData = '{"params": {}, "jsonrpc": "2.0", "method": "foo.method", "id": "bar"}';
console.log(d3.xhr(rpcUrl)
.header("Content-Type", "application/json")
.post(rpcData, function(error, data) {
console.log(error);
console.log(data);
})
);