Instead of a static class property, you could use a PHP session:
class progress {
public function __construct() {
session_start();
}
public function getTotal() {
return $_SESSION[ 'total' ];
}
public static function setTotal() {
$_SESSION[ 'total' ] = '123';
}
}
If you’re doing more complex stuff, a session wrapper like Symfony’s might be a good idea.
Related Posts:
- Using Ajax with a Class file
- Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
- How to modify wp_ajax function?
- Ajax Request not coming back to class
- wp_ajax action is not running
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- add_action and Ajax
- WordPress Ajax Problems
- Placement of add_action() for ajax callback?
- admin-ajax.php ” Missing argument 2″ warning
- Code run fast on a cronjob but slow with a do_action or ajax call
- WordPress ajax-action how to return content
- WordPress action – Pass arguments into action in an AJAX call?
- why does not work ajax that add_action registered in wordpress
- wp_ajax action is not run when ajax trigger
- Sharing variables in both actions wp_footer and wp_ajax
- Ajax callback not work
- admin-ajax.php calls fail if referrer is sent with 500
- How to run an ajax call in elementor editor
- do_action won’t work in ajax callback
- Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]
- Its possible to ajax update the content of the admin custom post type list
- Trigger action via button
- Why function called by admin-ajax executes synchronously?
- where does my function output from load-* go?
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- wp_set_auth_cookie() doesn’t work in Ajax call
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- SSL breaks customizer: page isn’t returned from ajax
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Ajax function returns -1
- Problems with creating sortable sections in customizer
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- Filter WP user acf field by ajax
- fetching via fetch/ajax gutenberg block data from third party
- How to make ajax content indexable by search engines?
- Conditional action hooks
- AJAX requests broken due to HTTPS for wp-admin
- query vars in url work but not in ajax call
- Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?
- How to make get_theme_mod work with AJAX in the customizer preview
- How to declare a JS variable in an AJAX call
- Fatal error: Call to undefined function get_post() with ajax
- how to send Ajax request in wordpress backend
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- Plugin: AJAX query external API to sync to tables
- splitting the URL using jQuery
- How do I get reusable blocks via frontend REST API?
- Is there builtin way to use protected AJAX endpoint?
- WordPress admin-ajax.php not available for subscribers/contributors
- WP Ajax never returning any data / calling action
- Refresh Markercluster after ajax call
- How to load content from many posts on a page, only if needed
- Mapping Backbone Models to serialized array in wp_options table
- WordPress Settings api data not sanitized if i use ajax
- Ajax login without redirect/reload
- wp_mail 200 response but no mail sent
- Pagination Using ajax
- Ajax call with javascript in post content (not enqueued)
- What’s the latest I can hook into wp_ajax_%?
- Nonce doesn’t validate in nopriv call
- How to use ajax to get multiple outputs?
- Get returned URL from wp_remote_post if response code is 302
- Change URL without reload Ajax
- Admin-ajax.php 400 error in custom theme
- Why does check_ajax_referer give a 403 error on https websites?
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- Hide Load more Ajax button if there is no more users to load or less than the number?
- How to get setting from separate file?
- Contact form – ajax, wp_mail
- WordPress function not defined in AJAX call
- AJAX not working when clicking load more button, when two terms are present in tax_query
- AJAX – get_posts for a specific post type returns empty
- Admin Ajax always return 0
- Ajax call undefined index
- Is there a hook that fires after an ajax call?
- Dynamic Twitter card images
- error_log() not working within wp_ajax_{action} handler
- Is there a way to add ajax hooks without editing the functions.php file?
- Implement AJAX to fetch pages or posts content in a WordPress custom theme
- Assign author on ajax wp post insert
- Ajax a php file that has Advanced Custom Fields in it
- AJAX is not submitting data to database
- Display SOLDOUT text in Dropdowns of Variable Product in WooCommerce [closed]
- Using AJAX to load div doesn’t always work
- Turn a URL into content preview
- Deploy Subcategories with Ajax not working
- Allow guest to update custom post met using ajax
- Simulate a specific page when making AJAX calls
- How to load post_meta for custom post type via Ajax
- ajax response is 0 instead of ‘script’ [duplicate]
- using ajax to query sql
- A refreshless WordPress website
- get_template_part() does not render after the ajax request
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php