First issue- you can’t access any data because your AJAX request is an entirely separate request from the one that loaded the page you’re making the request from. This is not unique to WordPress. You have to pass the data you want to operate on along with your AJAX request.
Second issue- calling your plugin file directly is not the correct way to handle AJAX requests. You won’t have any access to WordPress functions this way unless you manually bootstrap WordPress. Read AJAX in plugins for the correct way to handle AJAX requests in plugins.
Related Posts:
- Admin Ajax is returning 0
- How does admin-ajax.php work?
- is_admin() returns true when using admin-ajax.php from front end script
- How to save dismissable notice state in WP 4.2?
- Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”
- WP List Table custom quick edit box – post meta data missing and columns change on submit
- Conditional check for front-end which includes ajax
- Is it possible to hook AJAX to UPDATE-button?
- Is it safe to post form data via Ajax to the settings api? Am I missing something?
- Help with shortcode in admin-ajax [closed]
- Restrict function call to page load but not ajax call
- Determining whether it’s a AJAX call from front-end or from back-end
- Wp ajax not working from “current_screen” admin hook
- How to fix: Clicking ‘Quick Edit’ link in Admin (edit.php) makes posts disappear?
- Add a Separator to the Admin Menu?
- Adding a custom admin page
- Custom admin email for new user registration
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- localhost/wp-admin on my local redirects to production site’s /wp-admin
- How do I set up a webhook?
- wp-admin – save options without refreshing?
- How to retain HTML5 Attributes on Markup
- Gallery Settings Change available Columns
- Hide Admin menus per role in WordPress
- Dynamically Set WordPress Post Title To The Category Name
- jQuery Autocomplete not working with wp_localize_script
- How to find out if an wp-admin action edited a file?
- Text snippets shared across posts
- Add Admin User via SQL
- Add number new posts (post_status = pending) to administration menu [duplicate]
- How to remove Gravatar from Username column
- Page only shows when user is logged in (even with visibility set to public)
- I keep getting logged out in Firefox
- get_template_part in admin
- Why Jetpack is missing the “Feedbacks” menu item? [closed]
- Getting the different post statuses + count like in edit.php, in a custom submenu page
- What is the optimal way to filter out subpages from admin?
- Create a Meta Box in the Admin User Screen?
- Send email to Admin when user/member updates specific user/member data
- Protect custom php file with login
- Remove the whole menu in the admin
- Does wp_localize_script call a Javascript Function or Simply Pass PHP Parameters to It
- disable admin-bar search field for specific roles
- Limit Words in Category / Term Description – Admin Panel
- Change admin logout URL
- Link to post author but exclude administrator (on single.php)
- Why is this Ajax not working?
- Don’t attribute content to admin users
- wp-admin post.php JavaScript Links Not Working
- How to set default editor tab
- Admin Taxonomy Terms – Orderby Term Field
- How do I add an admin notice within javascript in the admin interface for posts?
- Admin toolbar shows up when not logged in
- How to localize admin.php only once
- Attachment display settings only allows “full-size”
- Admin option sidebar count
- 500 internal server error on wp-admin only
- WordPress administration Over SSL – To Force SSL Logins and SSL Admin Access
- Update Data parameter of a wp_localize_script() call
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Only Admin can Edit, Delete or Update
- Set Edit Post meta boxes inactive
- How to verify nonces in bulk?
- Getting admin notices to appear after page refresh
- Hide post title input for all roles except admin
- How to activate the dashboard
- Create WordPress posts from JSON array using plugin in admin
- avoiding the display of certain categories to certain user roles at content entry time
- hide elements of admin with css file
- Ajax call through admin-ajax.php returns 404 error
- Excerpt showing under title in admin columns
- how to remove +new from wp admin area
- html id is removed for non admin user?
- Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
- Dynamic WordPress Admin Panel
- How to show a custom notification to a specific user?
- Visual Editor only working for the admin user
- How should I change the username of or delete the admin user?
- Prevent Registration Where Role is None?
- Extending the user profile [closed]
- Any known plugins for master admin login to edit all on front end?
- How to exclude some post from admin edit screen
- How to show WordPress admin dashboard forms on front-end?
- Allow custom REST route to return before doing long operation
- WordPress – add help text under category list(right side) in post edit page
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Show only content in page after action click in WordPress admin
- WordPress4.1.15 Dashboard links not working
- Admins loggin in to our wordpress site default to the admin page
- ‘Conflict’ with action deleted_post and is_admin()
- Downloading file from wp-admin folder
- Dropdown list of available posts for post editing
- Unsure how to add simple checkboxes that write to a small table to admin
- Custom styles and scripts for specific admin screen
- Add Sort Link in Custom Post Type List
- TinyMCE buttons broken
- local WAMP admin user has lost privileges
- Is it possible to get rid of admin new updates notifications?
- WordPress 4.5 Inline Link Toolbar not working on custom wp_editor instance
- Cant enter admin page with SSL