Your list.php
file does not load any of the WordPress Core, at least there is no indication that it does based on the code you posted. Thus, WordPress classes and functions are not going to be available, hence the error.
Merely having a file in the theme folder does not mean that WordPress will load the file, or that when accessed the file will be loaded in a WordPress context.
Do the right thing and use the AJAX API for AJAX requests. That is what it was meant for. You are doing this the hard way, and the painful way. There are plenty of examples in the Codex for using the AJAX API and plenty of questions here about it as well. Get started. If you have trouble, edit your question with the specifics.
Related Posts:
- Get Previous & Next posts by Post ID
- AJAX Implementation
- Custom ordering fails after AJAX post filter
- Updating a checkbox value to database for specific row in table
- How to handle 400 status in Ajax [duplicate]
- Send checkbox status with Ajax / JSON and save it
- Not getting ajax success response on insert/update row to database
- Issue developing an AJAX form with WordPress
- Error while submitting form using AJAX and php
- How to use Ajax with WordPress
- jQuery’s .on() method combined with the submit event
- Why use admin-ajax.php and how does it work?
- Why is die() used at the end of function that handles an Ajax request?
- Making my AJAX powered WordPress Crawlable
- WordPress Ajax Data Security
- Why is a 500 error generated by admin-ajax.php not going into the Apache error log?
- admin-ajax.php doesn’t work when using POST data and Axios
- Custom Form with Ajax
- How to process ajax requests correctly using ajax plugins
- Gutenberg – how to correctly perform ajax request on backend
- get_template_part execute with ajax
- How to add WordPress nonces to ajax request
- How is it possible that the function of the test page works, but it does not go live?
- jQuery Autocomplete not working with wp_localize_script
- Is there a way to optimize function that is used for returning data in an ajax-call?
- WP REST API route request explain
- Ajax returning correct data BUT at wrong place
- get_posts empty when called via Ajax
- admin-ajax.php mixed content
- WP-API and Basic Auth returning 403 on POST but not GET
- Is there a hook to process a backbone restful PUT request inside wordpress?
- Check if username exist with AJAX
- How to localized one js file for different actions?
- Call javascript function when category was added via ajax
- Using AJAX with Forms
- json encode not work in wordpress
- wordpress and add actions to button by coding
- Get Author Post on author.php with AJAX
- Can’t publish post using ajax
- Ajax in plugin settings page returns 400 Bad Request
- Admin-Ajax Error
- WordPress Ajaxify Problem with Scroll-to [closed]
- Refresh table data with Ajax
- Stop ajax listener from sending empty parameter to function
- Can’t trigger an AJAX function with a submit button in the dashboard
- “Loadmore” button is not working in buddypress [closed]
- Uncaught ReferenceError: the_ajax_script is not defined . How is this not defined?
- infinite scroll not working when logged out
- Right way to include blog-header.php?
- AJAX action through direct link
- Ajax call on new site with jupiterx theme getting 400 response [closed]
- I can’t get a return value from Ajax
- WordPress AJAX return 0 – My case
- Creating an auto result search bar
- update_option is not saving an array, but saving the string ‘Array’
- Ajax call in wordpress not working for subscriber user
- Upload data from weather station to WordPress Website
- Ajax call in WordPress – unable to display the data on the page
- How to reuse get_template_part() containing a simple loop to work with AJAX correctly?
- Need help with ajax
- How to use AJAX in WordPress in MYSQL query?
- Using nonce when loading posts with AJAX
- What WP-API authentication method should I use to interact with anonymous / not-logged visitors?
- Processing ajax call to php to insert into mysql database
- WordPress Insert not working with ajax
- How to call ajax in plugin file
- Get title and featured image using Ajax
- javascript onClick update user_meta from jquery.ajax
- How to ignore WP_ERROR caused by “get_the_excerpt” method in an AJAX call?
- WP_Query is not received in Ajax
- My function containing a mysql query launched by ajax is not working in wordpress. What am I missing?
- How do I mitigate replay attacks when talking about actions that shouldn’t happen twice?
- Updating Jquery object with newly created elements after AJAX call
- Wp admin ajax load more
- wordpress ajax search posts
- Ajax call from Plugin using Class
- enqueue style using admin-ajax.php
- How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?
- Can’t get next post info with ajax
- How to inject data content from external json into a modal, using UIkit?
- Ajax by worpdress affects called jquery inside template file
- AJAX form not working, still reloads on submit
- Call public static method from ajax ‘wpcf7_mail_sent’ hook
- Update user meta via ajax from frontend, saving issue
- How to get the admin page slug using wp_loaded hook?
- Edit user meta on front-end via AJAX
- How to paginate Ajax result
- Having a self updating list
- Ajax not updating to database
- MySQL query in WordPress with AJAX
- First time doing Ajax with WP, how to do it?
- Unexpected WordPress search results
- WordPress Get Header and Footer using in Admin Area
- Tie the sending of an ajax request to WordPress hooks
- AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
- ajax page template
- apply_filters, EMBEDS and AJAX not a friends? [duplicate]
- Using Javascript Callback from plugin in a theme
- Why does my Ajax Get request give a 400 bad request?
- Can’t have two simultaneous charts using Apex Charts