Site icon Hip-Hop Website Design and Development

Get the URL of the page from which an ajax request has been launched within ajax callback

I’m calling a server-side function written in PHP via wp-ajax. The server-side function eventually redirects to another page for an authentication step, and then redirects back to the initially shown page. For this to work in a generic way, I need to pass the URL from which the AJAX request was fired onto the server-side function. How can I actually do this?

When I try for example this, I get the link to wp-admin/admin-ajax.php

I know that I could in theory use window.hrefor whatever in js and send that to the server, but I want to avoid this extra-piece of data sent, as I’m thinking that there must be some built-in wp feature for this…?