Retrieve data from a holiday service using D3

I have a working web service at http: // localhost / RestService / GetTransactionByStatus / 1 . When I run this URL in my browser, I get the correct JSON response:

{ "transactionConcil" : "TRANSACTIONS OK", "numTransactionConcil" : 0, "transactionNoConcil" : "TRANSACTIONS NOT OK", "numTransactionNoConcil" : 0 } 

How can I manage this REST service to present the correct data in my browser using a web service? The data will be managed dynamically, so the information that will be displayed depends on the identifier (the last parameter in the URL).

+7
source share
3 answers

See the documentation . Here is an example:

 d3.json('http://localhost/RestService/GetTransactionByStatus/' + id, function(data) { console.log(data.transactionConcil); }); 
+18
source

Starting with d3 v5, it has become

  d3.json('http://localhost/RestService/GetTransactionByStatus/' + id) .then(function(data) { console.log(data.transactionConcil); }); 
+1
source

Update 2019:

For any host - localhost host or any server you can directly receive data by simply specifying the rest api path so that your code can be used on any server

 d3.json("/RestService/GetTransactionByStatus/" + id, function(error, data) { console.log(data); }); 
0
source

All Articles