As per confirmation from @Jacob Peattie, my understanding is now this (if it is helpful to future readers).
AJAX calls to a WordPress plugin method exist in a totally separate context (separate requests) from the object instance created when a WordPress plugin’s PHP files are interpreted when a page is loaded.
Therefore, a property that is given a specific value only during runtime (for example, $this->foo
), while being visible during a given session, is not guaranteed to be visible to an AJAX call. The AJAX call accesses the object’s property as it is set on new object instantiation OR if it were set or changed via and during the AJAX call.
To make a dynamic data change visible between JS and PHP files, even if belonging to the same plugin package, likely requires another storage method.
Related Posts:
- ajaxurl not defined on front end
- Why does WordPress add 0 (zero) to an Ajax response?
- Saving data-URI to media library
- Nonces can be reused multiple times? Bug / Security issue?
- How can I run AJAX on a button click event?
- How-to implement admin Ajax inside an admin WP_List_Table?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Empty POST data on server on AJAX request using Angular $http
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- Build path for a custom portfolio plugin
- Using AJAX in a plugin to submit form – REALLY confused
- wp_localize_script $handle
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- Adding callback function for wp_ajax_ has no effect
- get all products of one category
- Get returned variable from a function to add_shortcode function
- Plugin Settings not Saving on Ajax re-ordered table
- How to post form in ajax mode and handle it in wordpress
- Using Ajax call in jQuery doesn’t work in widget
- WP_LOCALIZE_SCRIPT doesn’t work
- Timeout on Admin-Ajax?
- Admin-ajax.php appending a status code to ajax response
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Ajax in WordPress – path issue
- Cannot search post by taxonomy
- WordPress Ajax callback function from plugin – OOP
- WP AJAX is not working, always returns 0
- Ensure function has completed before allowing another Ajax call
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- Fetching the value of forms in WordPress AJAX
- include wp-blog-header not working on MAMP
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- Slow WP_query due to nested wp_query. Need Suggestions
- Show special field when correct shipping is chosen
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Woocommerce checkout update totals with datepicker
- Including the necessary functions for a custom ajax registration form
- AJAX request not routing through proxy
- Get cat parameter from admin-ajax
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- Ajax on the Administration Side of plugin – returns 0
- How to do admin ajax request in a plugin for rest api
- Ajax action has 200 status but response of No response data available for this request
- Jquery php request is returning a weird result
- WordPress Does not grab the string sends useing AJAX response, wp_ajax hook
- Posts form with AJAX request – Plugin development
- GET request return value as error instead of success
- How to control ajax calls without effecting memory of server?
- Bad request 400 using class based files
- Forbidden Error in ajax call with wordpress
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- ajax stopped working when not logged in wordpress
- ajax call return 406 not acceptable for non logged users only
- ajax response strips multidimensional array and unable to decode
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Rate limiting ajax requests in WordPress
- WordPress Ajax not returning Response
- ajax-action.php can’t find added action
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- AJAX call of function containing javascript which is not loaded (Plugin development)
- Performing ajax request in wordpress
- Inserted data from database does not showing on front-page without referesh page?
- wp_ajax function return the html page
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- ajax multiple Values
- How to include files in the loop via ajax
- How to handle ajax Request in a complex-structured plugin?
- Using JavaScript in WordPress page to call for server data using AJAX
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Filterable posts using categories
- How to get values from Tinymce visual editor popup?
- Ajax Response Error | just getting error as the response
- How To do Ajax In WordPress Custom Plugin?
- PHP includes with AJAX actions
- admin-ajax.php returns “No Script Kiddies!” sometimes
- WordPress function is not called and ajax return 0
- Ajax call not working with
- Ajax functionality not being called under wordpress plugin
- Array/List Edit in Backend
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Ajax not working to insert, query and result data
- WP Cron as Fast as WordPress AJAX?
- WordPress plugin: admin-ajax.php not passing data to custom function
- Can’t get query string in ajax call
- Ajax url value to pass ‘variable’ to use in query
- Ajax functions – no access to wp-admin.php only online
- An adiitional function fires on my AJAX submit
- Fatal error: Call to a member function query() on a non-object in my ajaxpage
- Page reload occurs before request finishes
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Return custom product in ajax call loop
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
- WordPress plugin boilerplate AJAX functionality
- Issue in Creating Dynamic URL in custom wordpress plugin
- Does a wordpress custom plugin is fired by default on php theme ajax request?
- Can’t delete reported post