Call current post URL in ajax

you can retrieve the permalink of the current post in JavaScript with wp_localize_script.

juste try this code after the call of wp_enqueue_script

wp_localize_script(
      "script_id"
    , "object"
    , [
        "permalink" => get_post_permalink($post),
    ]
);

and then you can read the permalink in JavaScript in object["permalink"]