If you want to able to use the WordPress functions the your ajax call should be to the wp-admin/admin-ajax.php and you should use wp_ajax
hook,
take a look at What’s the preferred method of writing AJAX-enabled plugins? I posted a nice example of how to do that there.
Related Posts:
- When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
- Getting $comments outside the comment template
- How wp_ajax_nopriv since WordPress 3.1
- How to use get_option() without any filter?
- Custom Login and Registration form in Ajax
- Load more posts with multiple queries
- Viewing checkout page removes fees from mini cart
- Load MediaPlayerElement after Infinity Scroll loads more posts
- How can I display a PHP foreach loop’s answers by AJAX
- WordPress : using AJAX to get posts & Sidebar Content to an external application
- mailchimp integration on a custom footer
- POST 429 Error when trying to place more than 20 images into post at once
- How to submit form data in the same page in WordPress without reloading the page?
- Unable to show messages using ‘admin_notices’
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- How to Add Customizer Setting in Child Theme
- WordPress objects class reference
- Customizing gallery shortcode in 3.5
- global menus made from master site’s custom menus wpmu network
- Capability to edit own posts and not others
- How do you add pages on a staging server, and then move them over to production
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- Theme Twenty Fifteen: Customize Color Scheme Customizer
- Is there a way to create invisible pages?
- How to handle security on a wordpress site? [closed]
- Which freelance sites are recommended to find WordPress developers/programmers, etc
- Is it possible to set default values for custom fields in a custom post type while my plugin is being activated?
- Syncing Avatars across multisite
- WordPress Template not affecting the working, keeps defaulting to the index.php template
- Custom Widget form function common elements
- How to move the wordpress site from test url to main url? [duplicate]
- Preserve custom URL parameter after saving post
- add JS to multiple plugin admin pages
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- Ajax not working properly
- Warning: Creating default object… when altering Customize panels
- Follow me for WordPress blogs (multi-authors)
- Pagination Issues using WP_Paginate Plugin
- WordPress customizer Preview not loading
- custom theme ,add media not showing images in media library
- Get Image from Media Library with the Title
- How to add an extra variable to login and authenticate it?
- Color swatches on category page? [closed]
- Best practice – pages – ACF or inline coding
- Diffrent User registration form for doctor and patient
- User can not login
- wpdb custom tables without plugin
- Save & Reset button in theme-option with Ajax (without refresh)
- Add a searchbox to the body of a page
- Best way to allow overwriting images shipped with the plugin?
- How to put a site offline, including images?
- How to add css option to Header Image customizer?
- Static Front Page settings – distinguish between Front page and Post page
- str_replace inside specific css files [closed]
- How to print Array values of custom Fields Meta?
- Customizer JS API get value of customizer field
- WordPress archive index page
- Hide content and functions from specific user roles
- Translating (WooCommerce) placeholder text
- Woocommerce custom archive page custom content and shortcode
- Page flickers in customization mode
- We are facing this error in header unable to understand the issue
- When is the wp-settings-[time] cookie generated?
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Can we set a redirection with dynamic content in url?
- How to remove (…) from the post tilte on homepage?
- Need to add custom text field to Woocommerce under add to cart button
- Hide entry-header for a specific category
- How can I setup a development environment which auto refresh page when code have changed [closed]
- How Can I add show_post_count in get_archives_link?
- Trouble with custom login page
- I want to use a product thumbnail completely different than the product image
- How can I edit the WordPress menu link to allow fb: instead of http
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Change Dashboard menu position?
- Get site ID from attachment url?
- Customize WP website specific column with CSS
- Help needed creating a custom Hamburger menu in header
- admin aoolbar add_node() and pulling in my post slug
- duplicate featured image functionality in custom meta box
- How to automatically pull an information from a form field onto an other page?
- How to create a custom menu for specific user
- Custom Form Input not saving to Database
- PHP includes with AJAX actions
- In wordpress customizer api adding div wrap to control
- How to create 2 preview button in a post?
- Move text from the side of image to below image [closed]
- Change the default WordPress image on the dashboard login to a custom image [duplicate]
- Custom terms in custom category taxonomy
- Customize TinyMCE Buttons
- Setting Custom WordPress “Posts page” AS “Front page”
- Instead of Custom CSS Theme CSS is loading
- Custom Post want button to add image and save in Postmeta
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Is it possible assign a secondary existing role to already existing one?
- Set custom banner image size with wp_customize