JQuery Ajax Dismissing multiple times from a single request

I have an ajax call that fires several times but is called once.

function getManagers() { alert('ajax called'); var jqxhr = $.ajax({ type:'POST', url: '/Concessions/Ajax/Concession.asmx/Managers' }).success(function(data) { var options = '<option selected="selected" disabled="disabled">Select Manager</option>'; for (var i = 0; i < data.length; i++) { options += '<option value="' + data[i].ManRef + '">' + data[i].Description + '</option>'; } $('#Manager').html(options); }).error(function(data) { alert('error') }).complete(function() { alert('complete'); }); } 

The function is called inside my document readiness function , and I was hoping for a single call, but it seems to bring up any ideas several times?

+4
source share
1 answer

is there any chance that your script is loaded "n" the number of times, n is the number of ajax requests made.

You can verify this by looking at the source of the page and finding the script. I am sure the script loads several times.

+9
source

Source: https://habr.com/ru/post/1403927/


All Articles