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
- 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?
- plugin ajax to external php file always return null
- When to use action hooks and plugins
- custom changes removed after plugin update
- Woocommerce dependent plugin
- jquery not calling php function
- Pre booking doesn’t work with custom bootstrap modul in woocommerce [closed]
- jQuery for custom plugin not working with Divi theme
- Custom Pages for Woocommerce Product-Category Pages
- Woocommerce Minimum Price for a Composite Product to add in cart
- WordPress api call using wp-ajax returns error 400
- Using wpdb without loading all plug-ins via wp-load.php
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Get orders of a specific customer woocommerce
- Search users with custom meta data
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- How to change layout of shop page in wordpress? [closed]
- Calling a class method instantiated by ajax call in wordpress [closed]
- jQuery slider widget similar to cnet.com
- product available stock day by day
- Running JavaScript after using WooCommerce Filter Plugin
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- Calling PHP function with AJAX
- I have English words in Kurdish pages
- Mixed content error after adding SSL certificate
- Google Maps for Woocommerce Checkout
- “Enable Media Replace” plugin does not update serialized object in WPMeta
- Meta Key array building with multiple input values from fields
- How to solve Blocked a frame with origin from accessing a cross origin frame error in wordpress?
- Configuring default woo commerce login with modal popup
- Template conflict with WC Payment Method
- admin-ajax.php not working properly on subdomains
- Plugin with AJAX on subdomains causes 404 in console