First, like many things in WordPress, it’s not like someone decided “let’s make this neat and convenient”. It was more like someone slapped it together for something, then it got used more in admin, then it got used a lot in admin, then it became kind of practice to use it for non-admin as well. Or something along these lines.
Second, it’s not as much what it does, as knowing that it always does same thing. You have no idea what request to the arbitrary part of front end is doing. What if analytics plugin is running, counting it as page view? What if there is complex redirect logic that handles seasonal URLs? What if, what if…
Ajax endpoint is meant for ajax:
- it declares
DOING_AJAXconstant for context, many things look for it to skip doing whatever they are doing - it sets up HTTP headers and stuff
- it gives you basic code organization convention, including user/anonymous distinction
Related Posts:
- jQuery Plugin to use WordPress functions in AJAX request
- Ajax request sends url rather than data
- Cannot pass value variable to WP AJAX functions
- Best collection of code for your 'functions.php' file [closed]
- How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
- Help making my pagination plugin better
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- jQuery AJAX call not executing in Plugin
- Execute a function using ajax
- How to load plugin before the wordpress jquery?
- Why is my ajax call refreshing the page?
- Admin-ajax.php is dying “0” without processing function
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Ajax with jQuery UI dialog not working
- ajax front-end increment views on click
- Add get_option to jquery
- Check if email address exists front end with AJAX in a plugin
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- AJAX button run function
- Bootstrap Drop Down menu is not working
- Form isn’t inserting data into database with ajax plugin
- How to put JQuery/Ajax inside shortcode?
- Ajax contact form widget plugin data not insert in database
- How can I inject options into an select tag inside the widget form?
- Display wordpress post’s in popup?
- Using color picker in plugin, does input attribute order matter?
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- Post Comments with Ajax in WordPress
- how to insert data in wordpress table usnig jquery ajax
- Display Custom Field Value on Admin Page Column
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- wordpress add_action() issue in ajax call
- How to display checked posts on another page over AJAX? (like comparasion style)
- Create WordPress posts from JSON array using plugin in admin
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- JQuery prepend a function
- I changed .live() to .on() but change is not reflected on the server
- How to get specific string/value from an array? php [closed]
- Where Should i write the code for wordpress ajax voting?
- Api external with wordpress
- Remove value from array within post meta ajax admin
- How to include my Ajax calls in one function instead of calling different ones every time?
- Call javascript functions from each page
- Using AJAX to run SQL statement and populate dropdown
- grab or load text on demand
- Adding a jQuery modal dialog to the admin area
- sliding/fading header plugin or approach suggestion
- What is the most efficient way of adding additional functionaliy for admin only
- wc_get_template_part doesnt display the content [duplicate]
- Jquery POST Ajax Return null data in wordpress
- How do I reinit WordPress plugins dynamically using jS?
- Why do I need to reload the page for WordPress to see the new custom field added with jQuery
- WP Ajax DB issues
- Ajax Call not Working in Plugin
- jQuery Ajax not loading page with ACF fields
- JS working when used normally but not in wordpress
- checkout stripe with plugin contact form
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- Update User Meta Via Ajax
- Compare Ajax Data Results
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Overwriting Plugin’s Ajax callback function from theme
- Help with customising love it plugin (use within foreach)
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- WordPress Feedback popup with date saved into table
- Not getting result using ajax on wordpress
- WordPress ajax not working in registration
- AJAX login without a plugin does not work. when add a action to function.php
- AJAX doesn’t pass variables to the php function in the plugin
- Like/Dislike Bar not working when updating
- Ajax, jQuery and WordPress
- Hyperlink to execute PHP
- How to get site homepage from plugin?
- WordPress plugin ajax post parameter
- admin panel save option with ajax
- how to call jQuery in admin as well as in homepage
- Load css classes after using ajax calls
- Jquery post responses 500 error after some time and lastly an 503 error
- Ajax button “Load more” is not loading correct language version posts for logged out users
- Ajax response from Media Selection does not update ALL information more than once
- Simple ajax request with Vanilla JS keeps given 400 Bad Request
- How to include admin-ajax when loading external javascript
- woocommerce target button with class after ajax update
- Function to prevent users from trashing comments
- Hook to plugins admin settings
- How to remove custom post type and add category and post name
- How to prevent additional code in functions.php to be removed once there is an update?
- Plugin not working & permalink erorr after upgrade to php 7x on Nginx
- Opening a JQuery modal window on click of a button with a JQuery plugin
- Woocommerce singe product custom gallery output works just on the first slide
- strange shortcode error: does shortcodes requires any dependency?
- Removing the custom_image_header from wp_head
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- Nested DIV’s across functions in PHP, do not seem to work
- Can plugin automatically update if i hide the update notification?
- Woocommerce – Product Description heading [closed]