prevent an ajax request firing twice with jquery

Solutions on MaxInterview for prevent an ajax request firing twice with jquery by the best coders in the world

showing results for - "prevent an ajax request firing twice with jquery"
Eleonora
08 Feb 2019
1$(element).off('click').on('click', function() {
2    // function body
3});
4
María Alejandra
12 Jun 2020
1$(element).off().on('click', function() {
2    // function body
3});
4
Cedric
10 Oct 2020
1var ajaxLoading = false;
2$(document).ready(function() {
3    $('#ajaxRequestor').click(function(e) {
4        e.preventDefault();
5        if(!ajaxLoading) {
6            ajaxLoading = true;
7            $('#ajaxContentPlaceholder').load('/path/to/content.html', 
8                function() { 
9                    ajaxLoading = false;
10                }
11            );
12        }
13    });
14});
15