I have been hitting the same posts and API documentation for hours and I just can't seem to get this combination right. I am using D3JS v4.
I need to send a variable number of parameters to a PHP script which will return json back to me. At the moment the only way I've been able to get my parameters passed is to manually concatenate the URL together, which isn't realistic. Something like:
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 have tried to use 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 have also just tried passing a flat string instead of the data pairs, like "id=1234&type=foo"
But nothing seems to be actually passing to the PHP script. Can someone clear this up for me? How do I call my PHP script, give it X number of params so the script can dynamically run my queries and return the data to me in JSON?