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
- WordPress REST API FormData: Form Not Submitted When No Files Attached
- PHP “php://input” vs $_POST
- How to solve the error “SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.” in IE
- How to add to cart via AJAX Woocommerce [closed]
- How to override WP_DEBUG for Ajax responses?
- Call to undefined function add_action()
- Including WordPress in RESTful API
- Registering AJAX callback function that is part of a class without instantiating the class in function.php
- How to tie built in AJAX to an add_action?
- admin-ajax.php vs .load() in WordPress
- Refused to execute script from ‘***’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled
- AJAX call using admin-ajax URL is returning 400 bad request
- Ajax response is always 0
- Ajax with OOP doesn’t work
- Error 400 bad request using admin-ajax.php
- Using AJAX to return search form results
- Setting TinyMCE Content in wp_editor
- Ajax is not working for logged out users
- WP Ajax Action Not Picking Up Query String Parameter
- How to use wp_send_json_error?
- Ajax Redirect role = ‘Editor’ to their Dashboard after register
- WordPress AJAX Call Not Return Result
- Form data is empty while posting form through ajax using jquery in WordPress
- load next and previous posts by Ajax and URL update
- Why would admin-ajax.php redirect to the home page for logged out users?
- wp_localize_script escaping my url – fix or alternative
- Insert wp_editor on front-end with AJAX?
- Buddypress: Load Ajax Without Template Pack [closed]
- How can I use AJAX to save/update a widget form?
- Implementing an AJAX POST API call in wordpress
- Woocommerce Ajax Add cart not working
- I have to post data by AJAX in wordpress to another Website
- Placement of add_action() for ajax callback?
- WordPress ajax problem need wordpress expert?
- Identical wp_rest nonce returned from rest_api
- Ajax WordPress Login needs to be stayed in current page Url without redirecting
- wp_ajax function did not call
- wp_handle_upload returns empty error array
- Loading comments in ajax – comment-reply function missing $args
- Woocommerce update product price via AJAX
- How do I query posts by a sub value with the API?
- Popup or admin/update notice on post/page edit screen without page refresh
- Frontend Post with JQuery AJAX to Php Issue
- Enqueue script in plugin is not working
- Single page site + pushState?
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- Load more posts (Ajax) in tabbed sidebar on single.php
- Something strange with ajax
- REST public POST giving 403 forbidden nginx
- Content including hooks inside wp-settings.php are being called twice in WordPress
- JS global variable doesn’t update
- 404 error custom post type rest api
- Load .php file into div using ajax
- AJAX admin Internal 500 error Failed to Upload
- Class property not visible inside ajax callback function?