In my Yii2 application, I have the following URL manager configuration in config/main.php:
'urlManager' => [
'enablePrettyUrl' => false,
'showScriptName' => false,
'rules' => [
],
],
When I make an AJAX call like this, it works fine:
$.ajax({
url: 'index.php?r=bankruptcy-rest/membership',
type: 'POST',
...
});
However, when I change 'enablePrettyUrl' => true, the AJAX request no longer works.
I want to use a standard URL in my AJAX call that will work in both cases (whether enablePrettyUrl is true or false).
What’s the best practice to define the AJAX URL so that it works reliably regardless of the enablePrettyUrl setting?