I am make an interactive map in D3. I stored all data in MySQL database. Since the user is able to select year to see all data, I have to pass the year to server side(php) to query about the data of the specific year.
I do not know specific function in D3.js to help us pass variables to php, so I use XMLHTTP to send information to php.
My javascript:
a = "ARGGDP"
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "database/allcountry.php?a=a", true);
xmlHttp.addEventListener("load", ajaxCallback, false);
xmlHttp.send(null);
function ajaxCallback(event){
alert( "loaded");
}
My php
header("Content-Type: application/json");
$a = $_GET['a'];
$username = "root";
However, it shows "Undefined index: a". Any idea about what should I do to fix this problem?