Just saw it… …in your HTML, take the action out entirely. We’re not using the HTML to tell the form/submit button what to do, we’re using JS/AJAX for that.
<form method="POST" action="<?php echo admin_url('admin-ajax.php'); ?>" id="modal-form-ajax" autocomplete="off">
Should become:
<form method="POST" id="modal-form-ajax" autocomplete="off">
Also, instead of targeting the form, target the submit button, so the following:
$("#modal-form-ajax").submit(function(e){
e.preventDefault();
Should become:
$("#submit-btn").on('click',function(e) {
e.preventDefault();
Related Posts:
- WordPress Ajaxifying not working properly
- WordPress Custom wp mail template return full template
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- When should you, and when should you not, use wp_list_pluck()?
- Use AJAX in shortcode
- Display random categories on the front page (Finding and Editing Theme Functions)
- Is it possible to remove the “standard” post format?
- Woocommerce add to simple product attribute programmatically [closed]
- Issue with get_theme_mod returning a blank value instead of the saved value
- How to remove row-actions from pages table?
- How can I get $id variable in widget’s form function?
- Refresh page after form action
- contactform7 remove tags with “wpcf7_autop false” from functions.php
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Add new user : make the fields First Name and Last name required
- How to change form action of wp-login page with a function
- i can’t use wordpress functions in ajax loaded php file
- How would I correctly implement a new if statement in a child functions file?
- Multiple Notifications SetInterval
- Function stops working
- Woocommerce custom calculation function
- Remove all video attachment, both files and post/postmeta from database?
- admin-ajax.php 403 forbidden only when calling from external file
- How to submit form data in the same page in WordPress without reloading the page?
- WordPress function with attribute pass to template
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- True email confirmation for registration (keeping unvalidated users from user table)
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- Replace image attributes for lazyload plugin on image elements with specific class
- Adding A New Widget to WordPress Disables the Existing Widgets
- How To Show Shortcodes In WordPress Custom Fields?
- How to create admin ajax function for my contact form
- Help! Need a different logo on my main page from my other pages
- admin-ajax.php & my wp-admin folder url showing in header
- Display page number on custom page title function
- wordpress function through ajax not being called
- same get_posts function works diffrently in tag.php and functions.php
- How to make an If Else on Excerpt Filter
- wordpress ajax is not working for dropdown selection
- How to replace words in my posts and saved new words
- How do I integrate my Child Theme into a Custom Template?
- Sending Messages Back to the Template After Processing?
- Shortcode to eliminate and replace with
- Automatic add space if user enters number(any digit)
- us states dropdown function and echo in theme template files
- functions.php filters not applied in AJAX call
- Add functionality to post editor
- custom post with loading script per single post
- Adding custom field in menu options [duplicate]
- Pass max posts to Javascript
- Updating site content after an AJAX call without a page reload
- Error function main() is a non-object to construct my Ajax.php
- Gravity Forms After Submission – GFFormsModel::update_lead_field_value?
- admin-ajax.php nulls all php variables
- Pass jquery var to a function in functions.php
- Get Value of Custom Field
- restrict access to specific urls on a specific period of time
- child_of not working while searching
- How to request login for user but not for bots
- functions.php / replacing div’s with new ones?
- Why does modifying my functions.php file always result in a server error
- Ajax call does not work for this custom code
- Syntax for a function in order to get post’s title in JSON encoded response [closed]
- Post variables not displaying correctly in custom function
- Why wp_ajax hooks doesn’t work?
- Remove snippets of JS from core
- ajax form function error
- Will my WordPress site become vulnerable after adding this functions which allows more HTML tags for subscribers?
- Removing Facebook contact field from user contact not working
- Help finishing script to export WP user data when form submitted
- How do I add functionality to images?
- AJAX values converted to PHP Variables?
- Explode Array from Repeatable Custom Field
- Directing to functions.php the correct way
- How can I json_encode the output of my function?
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- How to crop image in WordPress with aspect ratio for any size of image
- multible shortcodes (for differnt values) with one function
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Can’t find function which is called in a wordpress theme
- iOS and ajaxComplete
- post_row_actions filter from parent theme not executing in child theme
- get page_id in ajax to function in functions.php
- Customizer cuistom CSS Priority ordre Issue
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- CF7 Remove Comma from ‘select’ ‘radio’ and ‘checkbox’ outouts
- How to get variable from other function inside class function using add_action for Ajax call
- BuddyPress Edit activity function good practice
- wp_login_form display no styled form
- Advanced Custom Fields in WP_Query: Clickable Text in List Format
- comments_template() doesn’t work with ajax call
- How to use: WP_AJAX_GET_COMMENTS
- how to call a non-AJAX function from within an AJAX function
- Add custom css to specific user
- How can I restrict comments on WordPress, so only the POST AUTHOR and the user who commented can see them?
- How to redirect using a custom wordpress api endpoint after form submission?