how to prevent ajax from call twice

Solutions on MaxInterview for how to prevent ajax from call twice by the best coders in the world

showing results for - "how to prevent ajax from call twice"
Greta
19 Jan 2018
1$(element).off().on('click', function() {
2    // function body
3});
4
Gianluca
30 Jan 2019
1$(element).off('click').on('click', function() {
2    // function body
3});
4
Reece
07 Jul 2019
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