Your action name and hooks don’t match. You have hooked to _ajax_news
in the hook name:
add_action( 'wp_ajax_nopriv_ajax_news', 'ajax_news' );
add_action( 'wp_ajax_ajax_news', 'ajax_news' );
But the action you are sending in JavaScript is ajaxnews
, without the underscore:
'action': 'ajaxnews', //calls wp_ajax_nopriv_ajaxnews
See how your own comment has a different name than the actual hooks you’ve used?
Either the JavaScript needs to send ajax_news
as the action name, or the hooks need to be wp_ajax_nopriv_ajaxnews
. They just need to be the same.
Related Posts:
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How to create popup same as wordpress popup feature
- AJAX update fails for public/non-admin users
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Ajax, jQuery and WordPress
- Load css classes after using ajax calls
- How to load wp_editor via AJAX
- How do I only load a plugin js on it’s settings pages?
- How to pass JavaScript variable to PHP in wordpress widget?
- Create Proper WordPress Ajax Request in JavaScript, NOT jQuery
- Execute a function using ajax
- Errors while using ajax from external wordpress page
- Built in admin ajax hooks?
- How to use wp-ajax in wp-cron
- Dequeue / Deregister script and replace it with a new plugin
- Insert code after tag without using functions.php?
- How do I use WordPress PHP functions in my Javascript code?
- Admin-ajax.php is dying “0” without processing function
- how to use ajax to display from database and load more in wordpress plugin
- How to remove an Ajax action
- Passing select control value to block
- Has anyone used require.js for handling plugin scripts?
- How do I store information in a dynamic block in WordPress?
- $wpdb working with ajax but showing ajax error instead of success
- Ajax gives 400 error
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to load plugin after page is loaded – pagespeed issues
- Shortcode button dosent work for all posts. Work for first post only
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- React JSX in WordPress Plugin Development
- Simple ajax call not working in wordpress plugin
- Best approach to fetch data from wp options to js file or php file
- Updating the Drag-To-Share eXtended share URLs?
- __callStatic method handler passed to add_action causes bug in PHP
- Enqueue WordPress plugin scripts below all other JS
- How to add Internationalization in WordPress using Javascript/React?
- Using a custom plugin to capture input data via Ajax and PHP
- Ajax contact form widget plugin data not insert in database
- wp.media javascript issue with on select
- Ajax call returning 0
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- Create tabs in admin options page from custom post type loop
- How to load wp_editor via AJAX
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Redirect to another page using contact form 7? [closed]
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Submit Form data to another page via Ajax (WordPress Way)
- wordpress add_action() issue in ajax call
- WordPress front end AJAX. Return 0 :?
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- Asynchronous request in wordpress
- How to use custom Javascript code inside a plugin?
- Is there a better way of handling AJAX requests in WordPress?
- Calling a class method instantiated by ajax call in wordpress [closed]
- how to request a script more than once in wordpress
- best way to run a php script away from the template?
- Ajax call not working in wordpress through a plugin
- can’t unzip file
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- 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
- Error datatable whit ajax
- Cannot run script properly with my custom plugin
- Trouble with AJAX using GET
- Calling PHP function with AJAX
- Add style to body based on url
- How to properly enqueue jQuery knob on WordPress without conflict?
- Ajax Call not Working in Plugin
- JS working when used normally but not in wordpress
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- How to use Datatable with Ajax when creating plugin on WordPress?
- Problem with wordpress has_action() function
- Multiple image selection custom widget
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- How to use information from the database in the front-end?
- Conditional Fields depending on checkboxes
- Overwriting Plugin’s Ajax callback function from theme
- How to pass value from WordPress to Javascript
- My ajax request don´t work and return 0
- wordpress ajax pagination object value does not change
- How can I use wp_ajax_response for front-end error reporting?
- Javascript in plugin not working
- What’s the preferred method of writing AJAX-enabled plugins?
- Need to hide an element depending on date and post category
- How to get site homepage from plugin?
- get_option include in my adsense
- Capturing POST data
- Is it possible to run javascript on plugin deactivated?
- Ajax in Plugins: returns the whole page
- How to make a rest style plugin?
- wordpress Ajax success doesn’t return the value
- How to access values from your own settings page in javascript?
- How do I call an action hook into wp_ajax hook callback function
- Select posts from list and add them in a new list