You can’t hook into AJAX in a template, because the template’s not going to be loaded by admin-ajax.php when the request is made. You need to hook into AJAX when the plugin is loaded.
Since your hooks are defined in the class constructor (whether nor not this is a good idea is another issue), you need to instantiate your class whenever the WordPress admin is loaded. You could no this by putting $chart = new MyCharts\Chart()
directly in your main plugin file, or a file included by it.
Related Posts:
- Using Ajax with a Class file
- Ajax with OOP doesn’t work
- Ajax Request not coming back to class
- wp_ajax handler with multiple class instances
- How to implement AJAX within a class storing shortcode atts as class variables
- Cannot access class properties from ajax call in wpordrpess
- AJAX save options inside class
- Why can wordpress not find the actions I add in my constructor?
- Class property not visible inside ajax callback function?
- How to get data with Select AJAX PHP
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- Show spinner GIF during an $http request in AngularJS?
- ASP.NET MVC controller actions that return JSON or partial html
- How to check if I am in admin-ajax.php?
- Ajax in a settings page (update_option is undefined)
- gettext does not translate when called in ajax
- admin-ajax.php vs Custom Page Template for Ajax Requests
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- Is there a hook that fires before an ajax call?
- AJAX request from Chrome Extension to WordPress Website
- How to correctly load wordpress in a non WP script for AJAX request
- Minimal WordPress load for only `get_option` to work (because ajax…)
- Why is admin ajax reloading my page
- Plupload in metabox – AJAX action not working in Class
- Admin Ajax always return 0 on form submit
- Why this plugin doesn’t work with media upload page?
- CPU usage: AJAX and Heartbeat API on admin pages
- Solve cors problem using rest api or ajax
- Can part of my WordPress website be headless?
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Why does WordPress Heartbeat login not refresh the nonces?
- Why would admin-ajax.php redirect to the home page for logged out users?
- Admin Ajax and HTML5 Formdata
- Implementing an AJAX POST API call in wordpress
- WordPress ajax problem need wordpress expert?
- Identical wp_rest nonce returned from rest_api
- Ajax WordPress Login needs to be stayed in current page Url without redirecting
- wp_ajax function did not call
- wp_handle_upload returns empty error array
- Loading comments in ajax – comment-reply function missing $args
- Woocommerce update product price via AJAX
- How do I query posts by a sub value with the API?
- Popup or admin/update notice on post/page edit screen without page refresh
- Enqueue script in plugin is not working
- Single page site + pushState?
- Interim-Login form on frontend
- Ajax call does not work for this simple code
- WordPress ajax call returns a zero though die()
- wp_update_post onclick button using ajax
- Ajax insert or update data
- Check ajax triggered from front-end or from dashboard
- Localize script not working
- Add Ajax to rating button
- Why, if a function accepts arguments, it fails on ajax calls?
- wp_ajax declaration confusing for Front end
- How to disable drag-and-drop upload function in Media Library?
- WP_query offset seems to be counting draft post – AJAX load more
- Can’t retrieve any content from Ajax-loaded page
- adding ajax load more to display images from meta box
- Can’t load search results with ajax
- wp_ajax is not calling the action
- Deny dashboard access breaks ajax requests
- Run javascript upon successfully set featured image
- update_option in WordPress AJAX
- ajax in admin menu
- How to load dynamic option with ajax
- Auto-suggest to display meta-data, but not to include it upon click
- Register Template
- Ajax Favorite from foreach (how to specify which result result is processed)
- change wordpress pagination url after doing the request
- WordPress responds to the ajax request with readyState 1, 2, 3 before responding with 4
- Filter images from media library by guid meta field
- Counting Posts with multiple taxonomy and terms condition using MySQL and AJAX
- Refresh Gutenberg with JS for it show updated post
- How to Object.freeze wp_localize_script
- WordPress New Post via ajax call
- 400 Bad Request getting on AJAX Call
- admin-ajax.php 403 errors – no caching, permissions are fine
- How to add Ajax to this Pagination i made?
- Adding user using admin ajax by a user with custom role
- How can I run two AJAX requests simultaneously in WordPress?
- Issue developing an AJAX form with WordPress
- Ajax call not working anymore
- Ajax global variable is not getting saved (returns null)
- WP admin ajax Pagination issue
- Why function called by admin-ajax executes synchronously?
- (Frontend AJAX) get post data WITH image thumbnail?
- Load .php file into div using ajax
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- AJAX Post from same domain to a wordpress page
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Add Ajax loaded posts to existing posts
- Using AJAX for dynamic settings pages
- Change search to outpout category name instead of Post type name
- ‘Dehighlighting’ navigation once clicked
- AJAX admin Internal 500 error Failed to Upload
- $wpdb Ajax not redirecting to main page
- how reduce fetch/XHR response time
- Custom WP rest api endpoint only working on non https?