Your $_POST object will contain an array with the name 'data', as you are passing a JavaScript object.
I would recommend creating a JavaScript object and then using JSON.stringify() to pass to PHP. Try something like this:
JavaScript/jQuery
let ajaxData = {
firstname: $('#firstName').val(),
lastName: $('#lastName').val()
};
let ajaxString = JSON.stringify(ajaxData);
$.ajax({
type: "POST",
url: "b.php",
data: { data: ajaxString }
});
Then, in your PHP controller, you would do something like this:
PHP
$ajaxData = $_POST['data'];
$userData = json_decode($ajaxData, true); //Decodes JSON data and creates associative array.
You can check the structure using vardump($userData);