When site_url() and home_url() are different,
how a request should be directed to admin-ajax.php (both in front-end and admin)?
Using
A. admin_url('wp-admin/admin-ajax.php')
or
B. home_url('wp-admin/admin-ajax.php')
Usually method A is used. However for some websites this request gives error 404 in front-end. Method B does not work when wordpress is located in some sub-directory with respect to home_url().
Is there any method that works in all the cases when site_url() and home_url() are different?
See also here for the differences between site_url() and home_url(): What's the difference between home_url() and site_url()