How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?

How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?