Its looks like you are not printing the admin ajax URL.
add_action('wp_head', 'my_action_javascript');
function my_action_javascript() {
?>
<script type="text/javascript" >
jQuery(document).ready(function($) {
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
$('.myajax').click(function(){
var data = {
action: 'my_action',
whatever: 1234
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
$.post(ajaxurl, data, function(response) {
alert('Got this from the server: ' + response);
});
});
});
</script>
<?php
}
Please see that am printing the admin url using echo. Since there is no URL in ajax call you are getting the whole page.
Additional Info: For non logged in user, use wp_ajax_nopriv
Related Posts:
- Help making my pagination plugin better
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- jQuery AJAX call not executing in Plugin
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- Why is my ajax call refreshing the page?
- What’s the point of using WordPress’s built in admin-ajax.php?
- 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
- jQuery Plugin to use WordPress functions in AJAX request
- Check if email address exists front end with AJAX in a plugin
- 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
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- 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?
- Post Comments with Ajax in WordPress
- how to insert data in wordpress table usnig jquery ajax
- 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)
- woocommerce search by sku and title ajax
- How to include my Ajax calls in one function instead of calling different ones every time?
- Using AJAX to run SQL statement and populate dropdown
- Ajax request sends url rather than data
- Cannot read properties of undefined (reading ‘firstChild’) using photoswipe in product page
- wp_query ‘s’ parameter does not work with WC_AJAX
- 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?
- WP Ajax DB issues
- Cannot pass value variable to WP AJAX functions
- 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 ()”
- Not displaying Woocommerce product page in lightbox
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Overwriting Plugin’s Ajax callback function from theme
- 504 Timeout gateway when trying to pay for an order in Woocommerce. What else can I do?
- Help with customising love it plugin (use within foreach)
- WordPress Feedback popup with date saved into table
- WordPress ajax not working in registration
- 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
- 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
- Woocommerce attatch files and custom input meta to cart items and then to order
- Ajax response from Media Selection does not update ALL information more than once
- Hide prices and checkout functionality in woocommerce
- Function to Set Product type in Woocommerce [closed]
- Loading shortcode with ajax
- How to fetch serialized data from wordpress options
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Disable wordpress from including jQuery in the head section
- Woocommerce Shipping module available only for type of products [closed]
- WooCommerce – Adding Custom Order Without No Product [closed]
- How to remove an Ajax action
- Get Plugin Information from Multiple Sites Externally
- Plugin jQuery version VS Theme jQuery version: search for best practice
- Adding a jquery script to plugin contact form 7
- Why plugin ajax response is -1?
- Manually add order item with fixed product_id in WooCommerce
- WordPress Ajax Callback
- plugin ajax to external php file always return null
- WooCommerce shop page orderby [closed]
- When to use action hooks and plugins
- Reduce Drop down Menu Width in WordPress
- Loading jQuery UI in the head
- custom changes removed after plugin update
- Need to change url paramenter of share product pintrest [closed]
- How to modify WCMP Rest API response?
- Woocommerce dependent plugin
- jquery not calling php function
- CampaignMonitor for WooCommerce – Move subscribe button [closed]
- Pre booking doesn’t work with custom bootstrap modul in woocommerce [closed]
- jQuery for custom plugin not working with Divi theme
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- Custom Pages for Woocommerce Product-Category Pages
- Woocommerce Minimum Price for a Composite Product to add in cart
- this jQuery function works perfect in static html page but not on wordpress
- WooCommerce Shopping Cart Not Initially Showing Products [closed]
- WordPress API functions not working at AJAX functions.php call
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Compare Ajax Data Results
- Storing Array of values into wordpress options
- My AJAX API plugin isn’t working
- ajax sends data to plugin
- wordpress admin-ajax bad request 400
- Conclude woocommerce-shipping-totals