That will not work because you are referring to a single php file, instead the the whole WordPress environment.
There’s a easier way to use ajax in WordPress.
Use admin_url('admin-ajax') as the form action, then put the function that will answer the ajax call in the theme’s functions.php.
More detail here in this answer
Related Posts:
- How to update custom fields using the wp_insert_post() function?
- How to display multiple Post meta_key/meta_values by SQL query
- How to use multiple query with same meta key
- simple wordpress ajax plugin not working when not logged in
- Jquery ajax to custom php file: returning blank data
- Update WordPress Custom Field with AJAX on cached page
- How can update custom meta for all posts
- Is the regular ajax request method safe or I should use admin-ajax.php?
- AJAX in WordPress, sending coords data to MySQL and show after into map
- WooCommerce: update custom fields after checkout validation failure
- how to increase custom post value by one most efficiently?
- Ajax $wpdb not returning table data
- Checking for new message using AJAX and PHP. Server overload?
- How can I create a list of page titles from custom meta values?
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Refresh table data with Ajax
- Is it possible to retrieve all posts with a certain value for metadata?
- Non-Closing PHP Query in WordPress Loop
- how to get serialized post meta
- WordPress loop by meta key that is an array? and how loop multiple arrays
- A $_POST should occur when submit form but is not?
- How to store multiple custom meta box
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- How to use AJAX in WordPress in MYSQL query?
- Order a WP_Query by meta value where the value is an array
- Live search from database table
- Processing ajax call to php to insert into mysql database
- Add a custom class to the body tag using custom fields
- Define category ID using get_post_meta
- Add a counter for mouseovers (custom field)
- Hide a div when a custom field is empty
- WordPress stripping out custom field tags
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Order category posts by last word of custom field
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- How to update custom fields when post is published?
- What is the correct way to search 3 custom fields only in WordPress?
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- autocomplete in wordpress using ajax with json-data
- WP post meta – for loop inside for loop
- Remove item from post_meta array via AJAX
- When working with a post, almost all wp_postmeta are deleted
- Updating Lat and Lng of posts automatically gives sporadic results
- Prepared DB Query from _POST array
- Ajax not updating to database
- WordPress AJAX load post metadata in modal
- Include a custom field in mysql query
- MySQL query in WordPress with AJAX
- retrieve wordpress post-meta using php not wordpress functions
- If custom field doesn’t exist, or exists and it’s true show title?
- Metadata on the WP_Post object
- Trying to GET data with ajax from database and show in fullcalendar
- Custom field values to taxonomy terms
- Not connecting to database in file with multiple MySQL connections
- Way to bulk make all my tags lowercase?
- $Wpdb post meta query is not working with mutliple meta keys and values? [closed]
- HTML escaping data with ajax requests
- Display custom field on 404 page outside loop
- php include not working in custom page
- update_post_meta only updating on last loop of foreach
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- Get related product based on subcategory selected from category id with ID 142
- add category to posts with tag wordpress
- How can I Use 2 databases with one WordPress install
- Is there a hack for using is_page() within the function.php file?
- Why won’t this wpdb get_results query return results?
- Submit form to db
- Can not call .php files after switching to %postname%
- WordPress Conditional / Multiple Taxonomy Query
- WordPress low speed after migrating to new host
- WordPress Search Ajax + Isotope + InfiniteScroll
- How to call my PHP function with AJAX ? wp_query
- AWS Lightsail WordPress – connect to database on instance using mysqli
- No more get_option(‘date_time’) in WordPress 5.5?
- get_the_author_meta( ‘ID’ ) just return 1
- Using wpdb to connect to a different database is not working
- WordPress ajax filter returning all posts when it should be filtering by category
- Store custom field’s multiple values in one user meta key
- WooCommerce multiple custom fields code
- Insert data from form to database
- Post Meta statement?
- WP_query meta_query slow with OR and DATES
- Pass form attributes to another php template in wordpress
- meta field for numerous links
- Custom HTML form using PHP – help with ajax/username validation
- AJAX Returning Way Too Many Posts
- Conditional statement within WP SQL query
- Modify category archive page loop on functions.php
- two wordpress sites, two themes, one database, same content
- how to check for wordpress Query errors
- Showing custom field contents without listing description
- Custom query_posts() parameter
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- How to add together (get the sum) a field from all author’s posts
- Load php function with AJAX on modal window
- Query Concatenation
- Error resetting database index using ALTER TABLE in $wpdb->query
- ajax problems on loading page [closed]
- Shortcode Displays 2 times