I have a Javascript function which takes a parameter from HTML.
    function find(customer) {
        data = {"key":customer};
        console.log(data);
        var xhr = new XMLHttpRequest();
        var url = "test.php";
        xhr.open('POST', url, true);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
        xhr.send(data);
        xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
              console.log(xhr.responseText);
            }
        };
    }
The log produces the correct information, i.e.
{key:"103"}
Then in PHP, I'm trying to access this data like so:
if (isset($_POST['data'])) {
    $number = $_POST['data'];
}
echo $number;
However, PHP is throwing an error at me:
Notice: Undefined index: data in .\test.php on line 22
This means that if(isset($_POST['key']) is returning false, and I'm not sure why. I can find plenty of information using Ajax, but not much instructing me on using standard Javascript.
EDIT:
Changed $_POST['data'] to $_POST['key'] based on comments. 
Instead of index error, now receiving variable error (undefined).
Notice: Undefined variable: number in .\test.php on line 22
 
     
     
     
     
     
    