jQuery.ajax() results in a 403 error
That's because by default Drupal only allows GET request on default controllers. In your case you should create a custom resource.

Using resources has multiple advantages:


No custom paths per request method
Access control
CSRF protection
Using the API that the REST module in Drupal 8 provides


It basically comes down to creating a class with an annotation:

             /**
              * @RestResource(
              *   id = "my_resource",
              *   label = @Translation("Resource label"),
              *   uri_paths = {
              *     "canonical" = "/sample-page"
              *   }
              * )
              */
             class CustomResource extends ResourceBase {
                public function post($data) {
                  // Do stuff with the posted data.
                }
             }


Some more elaborate examples:

Example one

Example two

You will have to alter your jQuery POST request to something like:

 $.ajax({
         type : "POST",
         url: '/sample-page/',
         data: {'uid':2},
         success : function(response){
              console.log(response);
         },   
    });


The data you post in your jQuery request will be available in $data of your resource class.