<?php $js = <<<JS
jQuery('#forgot-password').on('click', function(){
jQuery.post('site/request-password-reset')
.done(function(result) {
....
})
return false;
})
JS;
$this->registerJs($js);
?>
<script>
var base_url = '<?= \Yii::$app->request->hostInfo . "/" . \Yii::$app->language; ?>';
</script>
jQuery.post(base_url + '/site/request-password-reset')
var passwordResetUrl = '<?= Url::toRoute([...]) ?>';