I have been writing the same messages and API documentation for hours, and I just can't get this combination correctly. I am using D3JS v4.
I need to send a variable number of parameters in a PHP script that will return json to me. At the moment, the only way I was able to pass my parameters is to combine the URLs together, which is unrealistic. Sort of:
var id = 12345;
var type = foo;
var url = "getNetworkData.php?id="+id+"&type="+type;
d3.json(url, function (error, data) {
if (error) throw error;
buildNetwork(data);
})
I tried using the following:
d3.request(url)
.mimeType("application/json")
.response(function(xhr) { return JSON.parse(xhr.responseText); })
.get( { 'id': id , 'type':type } , function (error, data) {
if (error) throw error;
buildNetwork(data);
}
);
Or:
var url = "getNetworkData.php";
d3.json(url, function (error, data) {
if (error) throw error;
buildNetwork(data);
})
.send("GET","id=12345");
I also just tried passing a flat string instead of data pairs, e.g. "id=1234&type=foo"
, , , PHP script. - ? PHP , X , script JSON?