To solve this, you need to unbind the event that triggers the second AJAX request. You need to make sure that your unbind()
function is called after the event binding has occurred.
So why not just load it in the footer? One reason is that the other script that binds the event might be loading in the footer, too.
To control the loading order of scripts, you can actually use the dependencies
parameter of wp_enqueue_scripts(). You just need to know the handler of the script that you wish do add as a dependency:
wp_enqueue_script( 'my-handler', 'script.js', array( 'another-script-handler' ) );
my-handler
is now depending upon and is therefore loaded after another-script-handler
.
Related Posts:
- jQuery’s .on() method combined with the submit event
- Nonces and Cache
- How to HTML5 FormData Ajax
- admin-ajax.php doesn’t work when using POST data and Axios
- Contact Form 7 Custom Post Action
- Custom Form with Ajax
- ajax – why multiple calls to wp_create_nonce() return same value?
- How to link WordPress heartbeat to ajax form
- Ajax form submission from admin panel
- Confused on AJAX submit form through page template
- how to use reCaptcha v3 in wordpress custom login form?
- submitting form via admin-ajax.php returns 0
- Admin Ajax and HTML5 Formdata
- jQuery Ajax passing empty parameters to my function?
- Using ajax with wordpress
- Using AJAX with Forms
- Ajax image upload with media_handle_upload and form.js
- Ajax post returning full html page as response
- Sending variable from ajax on form submit
- contact form ajax empty response error message
- Can’t trigger an AJAX function with a submit button in the dashboard
- Dynamically add more fields/remove last field in a form
- Ajaxify Form That Submits To Same Page To Display Post Data [closed]
- Using admin-ajax prevents regular php form submission
- Specify ABSPATH in jQuery url
- ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero
- Output multi-steps form results in same page
- Using get_theme_mod in php ajax form doesn’t work
- How to create a form button that executes a function?
- How to stop being directed to admin.php after sending request to admin-ajax.php
- How to display contact form 7 form in vanilla js without jquery in frontend
- Should wordpress nonce be placed in html form or in javascript file
- Add Server Side validation in Ajax mail form
- How to send automatic response after form submission without plugin
- Opening Modal popup on Ajax form submission
- Registration form AJAX check for existing username (simple version)
- Issue developing an AJAX form with WordPress
- Ajax show custom post data form & script
- Using AJAX on Contact-form the WordPress way
- Error while submitting form using AJAX and php
- Ajax contact form returnig 0
- Ajax Form data is not posted back to the get_results()
- Using AJAX for dynamic settings pages
- Ajax Form seems to post, but does not return
- Bad Request when adding new post via ajax form
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- Show spinner GIF during an $http request in AngularJS?
- ASP.NET MVC controller actions that return JSON or partial html
- How to check if I am in admin-ajax.php?
- Saving (Updating) Post / Page Edits With AJAX
- Is there a hook that fires before an ajax call?
- AJAX request from Chrome Extension to WordPress Website
- Minimal WordPress load for only `get_option` to work (because ajax…)
- Why is admin ajax reloading my page
- Admin Ajax always return 0 on form submit
- Why this plugin doesn’t work with media upload page?
- Ajax call in wordpress not working for subscriber user in front site
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- Solve cors problem using rest api or ajax
- Why does WordPress Heartbeat login not refresh the nonces?
- Embedded Twitter feed won’t render nicely when loaded via Ajax
- Using foreach inside an ajax function
- WP_User_Query ignoring ‘meta_query’ arguments
- Get the_content with ajax
- Caching-Plugins and Ajax-Page-Parts
- Ajax loading duplicate post
- Admin ajax error 400 when passing select value to populate another select
- How do I detect in which page ajax_query_attachments_args is loaded?
- AJAX request randomly stop working and returns error 400
- Ajax store response json in variables
- How can I set cookies on both secure and non-secure origins at the same time?
- Variable Products Being Added to Cart with AJAX on Shop and Category Pages
- ajax is returning 0
- merge wp rest api query to get posts per category does not work
- WP AJAX post filter > do something with empty value
- How to make a fetch() POST request to wordpress rest api?
- Load more posts in the same category – Ajax + Timber
- How to jQuery Ajax show new data from successful insert?
- is there’s a way to get the next page content generated by page break block with ajax call?
- How to get next and previous post into ajax formed modal windows?
- Passing value from select form with Ajax not working
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- Is there a public ajax endpoint?
- Why Ajax Doesn’t Work?
- How can i do public ajax call?
- How to prevent multiple post with same meta value being created simultaneously in WordPress (with ajax)
- Frontend AJAX Media Upload returning 404
- How to update cart total after AJAX success
- How to implement AJAX within a class storing shortcode atts as class variables
- How do I display posts of a specific day?
- (Frontend AJAX) get post data WITH image thumbnail?
- Ajax Function call is always returning 0 in front end(without plugin) [closed]
- AJAX Post from same domain to a wordpress page
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Add Ajax loaded posts to existing posts
- Change search to outpout category name instead of Post type name
- ‘Dehighlighting’ navigation once clicked
- ajax form function error
- Workaround AJAX calling without directly calling WordPress backend (Admin dashboard) because it is restricted to the end user (the public)
- Run PHPMailer function after ajax function completes that adds row to custom table