I am trying to make a xmlhttprequest from
d3.xhr("Data-mapper?Function-name=tree-data", "application/json", function (i,d){
console.log(d);
return d;
});
I am able to get the response data as well but i want to know if i can add a loading cursor when the call is made.. Or progress bar ...
One more thing i wanted to ask is how can we send data when we make a call to get data from server side i.e
d3.json(...) or d3.xhr(...)
You can add a "loading" screen by adding it in the beginning and removing in the callback:
addLoadingScreen();
d3.json(..., function(error, data) {
// do something
removeLoadingScreen();
});
I have used this technique here.
To answer your second question, you can pass parameters as GET parameters:
d3.json("http://www.foo.com/script?parameterA=foo¶meterB=bar", function(error, data) {
});
HTML
<pre id='pre'>loading...</pre>
JS
d3.json("http://filltext.com/?rows=5&fname={firstName}&lname={lastName}&delay=10", function (err, data){
var pre = document.getElementById('pre');
pre.innerHTML = JSON.stringify(d, null, 4);
console.log(data);
});