Best Practice for Calling Controller via AJAX with Pretty URLs Enabled

In my Yii2 project I have enabled Pretty URLs ('enablePrettyUrl' => true).
I need to call a controller action through AJAX, but I’m not sure what is the best/recommended way to build the URL in this case.

Could you please suggest the proper approach or best practice for making AJAX calls when Pretty URLs are enabled in Yii2?

If I understand you correctly, your question doesn’t seems to matter. It doesn’t matter if the URL is for AJAX, for a POST form or for the API call. You just call the Url::to() or Url::toRoute() and the URL is created properly.
Maybe you’re asking how to call an AJAX? But this is a question not related to the Yii. You can call it purely with Javascript, or use jQuery or you can use a great Pjax from Yii2 Pjax, yii\widgets\Pjax | API Documentation for Yii 2.0 | Yii PHP Framework