Send data via Ajax to set entity fields

I’m working on a custom module that works with Ajax to create or update entities. But I’m wondering how I can send data via Ajax to be set in the entity fields. So looking at the example to I fetch the my_id variable value 10 inside the mymoduleAjaxCheck function?

Focussing on the most important part of my code I have:

a my_module.routing.yml file:

  path: '/js/my_module/ajax/{nid}'
    _controller: 'Drupalmy_moduleControllerMyModuleController::mymoduleAjaxCheck'
    _csrf_token: 'TRUE'

I have a script.js file:

var my_id = 10;
  type: 'get',
  url: callbackUrl,
  dataType: 'json',
  data: 'my_id=' + count

And I have a src/controller/MyModuleController.php file:

* Controller routines for user routes.
class MyModuleController extends ControllerBase {
  * Saving entity
  public function mymoduleAjaxCheck() {
     // how do I get the ajax data variable my_id here?