Deviland
Deviland

Reputation: 3374

JQuery Ajax Firing multiple times from a single request

I have an ajax call that fires multiple 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 within my document ready function and I was hoping for a single call but it appears to call this several times any ideas?

Upvotes: 6

Views: 17573

Answers (1)

Kishor Kundan
Kishor Kundan

Reputation: 3165

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

You can check for this by viewing page source and finding the script. I am pretty sure that the script is being loaded multiple times.

Upvotes: 13

Related Questions