Ok got it, knew there must be some built-in WP solution to this. Simply call wp_get_referer() in your callback (for details, see this).
At least it’s working as I need it, let me know if there’s any better solution.
UPDATE
Thanks to @Tom J Nowell, we should also mention that referrers could get stripped for privacy reasons or similar. To thus be on the safe side, there’s no way around passing the referrer’s URL explicitely to the data sent across AJAX, like using document.location.href.
Related Posts:
- The correct method to pass query vars in AJAX using ajaxurl
- Dynamic URL to reference custom PHP files
- Concatenate site_url and string doesn’t work
- Removing all my hardcoded URLs with get_site_url()
- How to get URL of current page displayed?
- Comparing arrays within a loop
- Jquery ajax to custom php file: returning blank data
- Looking for a better way to handle an ajax script that pulls in post data on click
- Data fetch and delete by ajax request
- Debugging PHP object during Ajax call in WordPress
- Newbie question: no index.php? in my plain wordpress permalink
- Display notification only once
- admin-ajax.php returning error 400 namespaced callback
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- Why is this Ajax not working?
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Any possible way to make $wpdb->get_results() return anything else than array?
- How to make drop down post title
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- Ajax random number always the same
- Colon is Missing In My Website Url in WordPress
- Repeating admin-ajax.php not found error in admin
- WordPress, AJAX and pre_get_posts using conditional tags
- How to send Ajax request from my plugin in admin dashboard?
- get_children displaying images removed from the page
- Setting value of session with Ajax not working
- AJAX success response is not working but it’s saving my changes
- How to disable controls in theme customizer?
- Loading php file with AJAX in WordPress frontend
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- Unset session variable on page reload / setup but exclude AJAX
- Making an AJAX call to refresh a table
- Using data sent via AJAX in multiple functions on a WP plugin
- Woocommerce with Lazy Load php and ajax
- Short code template + ajax
- Can I make get_users() query global?
- My jQuery Ajax form submit is still refreshing page?
- Calling PHP Scripts in Ajax that are in PHP Snippets
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Simple jQuery AJAX Request fails to run PHP Script
- Allow user to Upload image and manipulate it on the frontend
- Call featured image url
- Execute Jquery when a specific page in my plugin is loading
- Use an anchor link to open an iframe inside a WordPress page
- Adding custom url to readmore link using get_permalink()
- How to set base url for php widget
- AJAX function not working [closed]
- what does $options = get_option(‘test_theme’); do?
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- Validating an email input from form field before submit using JQuery, AJAX, and PHP
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Unable to display multiple parameters from url by javascript through shortcodes
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- My Custom Post Type AJAX Query is Returning no posts – why?
- register_block_type is not working properly
- Current WordPress Page Title as Search Parameter into A Tag
- AJAX numerical pagination problem in TwentyFifteen-child theme
- How does one make a URL return dynamic JSON with custom Content Type?
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- wp_set_object_terms returns 500 error when called through AJAX function
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- autocomplete in wordpress using ajax with json-data
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- Remove item from post_meta array via AJAX
- wp_send_json erase last value
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- How to load WP_Editor JS files manually (with AJAX)?
- changing static link to relative link
- wordpress ajax pagination
- Submitting my form to the database and then redirecting to payment site
- Create a dynamic buddupress tab
- Pass the updated value of aid from form using ajax
- 403 (Forbidden) delete file image in themer folder
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- Problems with plugin that fetches data from database with ajax
- Dynamic Gallery
- Magento and WordPress URL integration [closed]
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- How to remove parent section in an attachment URL in wordpress?
- Jquery autosave text area after typing
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Remove Woocommerce product from cart with ajax/fetch
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Create a custom plugin with dynamic child pages listing database records
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Upload multiple files via ajax from an HTML file input
- How to pass javascript var to php var
- Ajax infinite scroll random order shows duplicate posts on custom post type
- Display posts based on the selected category when no subcategory is chosen
- Data insertion after clicking a button does not work (script, AJAX, PHP)
- WordPress Insert line in DB when clicking a button
- Woocommerce – how can i add items to cart using onclick – multiple items at once with custom prices