无法通过ajax将js变量传递给php

There were similar questions here, but I haven't found any solution to the problem. So I'm asking for help. Here is what I'm trying to do:

              $(document).on('click', '.edit', function(){
                           var my_id = $(this).attr('id');

                             clear_field();
                             $.ajax({

                                    url:"my_action.php",
                                    type:"POST",
                                    data:{action:'Edit', my_id:my_id},
                                    dataType:"json",
                                    success:function(data)
                                    {
                                     alert(my_id);
                                   $('#my_name').val(data.my_name);
                                    $('#my_id').val(data.my_id);
                                    $('#modal_title').text('Edit');
                                    $('#button_action').val('Edit');
                                    $('#action').val('Edit');
                                    $('#formModal').modal('show');

                                    }
                                    })
                             });

Code in my_action.php:

  if($_POST["action"] == 'Edit')

                {


                    $data = array(
                                  ':my_name' => $my_name,
                                  ':my_id' => $_POST["my_id"]
                                  );
                    $query = "
                    UPDATE tbl_my
                    SET my_name = :my_name
                    WHERE my_id = :my_id
                    ";
                    $statement = $connect->prepare($query);
                    if($statement->execute($data))
                    {

                        $output = array(

                                        'success' => 'Data Updated Successfully'
                                        );
                    }

                }

$_POST["my_id"] is always blank.

Console shows 'Data Updated Successfully', and when I change :my_id to some value, everything works properly (the mysql table is updated). alert(my_id) shows proper id. So I have no idea what else to check

I would really appreciate your help!

Can you check if the var my_id = $(this).attr('id');n is actually returning any value? you can use Console.log(my_id); and check in the browser developer console or use alert(my_id); to check.