Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Ajax Firing multiple times from a single request

Tags:

jquery

ajax

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?

like image 518
Deviland Avatar asked Mar 28 '12 14:03

Deviland


1 Answers

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.

like image 69
Kishor Kundan Avatar answered Nov 15 '22 01:11

Kishor Kundan