You can create an Ajax file for a specific page at the backend.
- If you want to create an Ajax file for an existing WordPress page, such as
wp-admin/edit.php
, create it in the mvc/admin/ajax folder with the same file name, so it will bemvc/admin/edit.php
in this example. - If you want to create an Ajax file for a custom page loaded with
?page=a-custom-page
in the URL, create it in the mvc/admin/ajax folder with the same value of the page parameter, ending with.php
, so it will bemvc/admin/a-custom-page.php
in this example.
Here is the path to the sample: mvc/admin/ajax/ajax-sample.php
. You can always clone it and then customise to your needs.
As long as you name your class as Ajax_Sample, it will be auto-instantiated.