Set FPDF Variable with value from another PHP File

I'm creating a web based php application using PHP. It requires the generation of an FPDF document (File B) utilising the value of an Text Field in File A on button click.

What I have tried: Creating an AJAX Query to pass the value from File A on button click to File B as follows:

$(function(){
$("#pdfdownload").click(function(){
var docid= document.getElementById('no_from_field').value;
$.ajax({
                url:"FileB.php",
                type: 'POST',
                data:{id: docid},
                success: function(res){
                        console.log("Success")
                }
        }
  })
 });

The issue, however is that the value is not being passed to the other page. If I try to access this variable on File B (The FPDF Generated File) as below:

$name = $_POST['id'];

It says that it is undefined. I further verified it by adding a condition to check if isset($_POST['id']); and it returns false.

As the value to be passed needs to change depending on the input in the Text Field in File A, I cannot use Session variables to pass the variables.

I want to know if this way of passing data to the FPDF file is the right approach, if not, please direct me to the right implementation.