First, everyone doesn’t say that. Everyone says to use admin-ajax.php
for ajax, which is it’s meant for, not form submissions precisely. It’s not as popular and well covered, but there is actually different endpoint for form submission — admin-post.php
.
The reasons are, however, same. What you cannot do in your plugin is reliably load WordPress core. When WordPress core loads plugins it composes coherent reliable environment, but it doesn’t work the other way around.
The point of using core–provided endpoints is precisely to rely on that environment.
Related Posts:
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Using Ajax with a Class file
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- Stop admin-ajax?
- Is it safe to assume that a nonce may be validated more than once?
- Using Nonces for AJAX that only retrieves data
- store/cache ajax sent data to avoid repeated request
- Trying to load content of a post via AJAX
- Insert Post using Ajax
- How can I automatically login using a URL?
- Run again current query via ajax but changing a var
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- Ajax requests with different WordPress Address and Site Address setup
- is_home doesn’t affect content
- Allow AJAX call to other roles than admin
- submitting form via admin-ajax.php returns 0
- Help add ajax load more button
- Conditional success callback based on Ajax Response not working
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- How to use several wp_ajax_ functions for different queries?
- Three level taxonomy dropdown frontend
- How to solve “Updating failed” with 403 Error when trying to save a Site or Post in Gutenberg?
- Keep getting 400 Bad Request error when trying out AJAX on custom theme
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Ajax simple experiment
- How to load new text widgets and polls into the sidebar without reloading the page?
- Updating User Meta with Array on Click of Button AJAX
- Why is on status span no search results?
- eventON plugin AJAX call triggers website crash
- Dynamically add more fields/remove last field in a form
- Save & Reset button in theme-option with Ajax (without refresh)
- Ajax Multi Response Problem
- Force redirect single.php to index
- Any plugin or Script to integrate ajax selection module into WordPress page
- Custom AJAX Endpoint not returning any result
- Contact form 7 Hide response messages after 5 seconds
- how should i get json encoded data from wordpress ajax action page
- Cache plugins and ajax nonce verification
- How to include php-generated javascript?
- Serve a different theme based on window size
- custom autocomplete search
- post values to custom post type which has advanced custom fields
- ajax problem – function on server is not called
- How to continuously send feedback via AJAX responses to my client?
- get current taxonomy post with ajax
- WordPress Ajax Filter
- I get a 0 after the result of my ajax requests
- Not getting an ajax readystatechange on my page
- problem using ajax url
- Problems implementing Load More functionality
- admin-ajax.php error 500
- How to display contact form 7 form in vanilla js without jquery in frontend
- Error sending array data from php to javascript
- Sharing variables in both actions wp_footer and wp_ajax
- Display full WordPress post under search form using AJAX
- Ajax callback not work
- jQuery.post returns 0
- Using wp_send_json_success instead of $result[‘message’], die, etc
- do_action won’t work in ajax callback
- Opening Modal popup on Ajax form submission
- Ajax sometimes work and sometimes just don’t work
- admin-ajax error 400
- 400 Bad request while submitting form using AJAX
- wordpress admin ajax trash_comment
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Its possible to ajax update the content of the admin custom post type list
- WordPress custom ajax login not working on mobile browsers
- Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php
- Javascript output now showing in custom widget
- Ajax call on class returns old data
- how to enable ajax on submitting of contact form 7?
- Create a post with REST API and adding a category
- how to correctly use json_encode with ajax
- How to trigger lost password email using REST API?
- Using AJAX on Contact-form the WordPress way
- Retrieve Header Background Image with AJAX
- How to block search engines indexing certain AJAX actions
- Error while submitting form using AJAX and php
- AJAX call in backend results in empty update_option
- Ajax Comment: Page reloads whenever the comment submission form is reloaded
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- wp_ajax_action, wp_ajax_nopriv_action not working
- get_comments() returns empty array if called through AJAX
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- How to get parent comment’s id?
- Static var overwritten with WP AJAX action, works fine without AJAX
- using ajax to query sql
- Dynamic dependent select box getting null value
- How to get data with Select AJAX PHP
- Add “load more” functionality to an AJAX response
- weird Internal Server Error – no error log produced
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?
- At what stage does wp_ajax hooks gets applied during WordPress request?