Chinmayee G
Chinmayee G

Reputation: 8117

IE: Clicking same button continuously sends same AJAX request multiple times

I've encountered a weird problem. I've bind click method to div using jquery one() method.

However, if I click on this div continuously then in IE its executes AJAX method 3-4 times. If I disable AJAX call and write some other DOM manipulation function, it executes only onces as expected.

I don't why but when I includes AJAX call something goes wrong.

I've created sample code at 'http://jsfiddle.net/MCY4A/' But not sure how to make AJAX call working here in jsfiddle

Somebody please help.

Upvotes: 0

Views: 566

Answers (1)

macroAbc
macroAbc

Reputation: 23

I may not understand your requirement properly but i assume you want to call ajax request only once on some div click , you can use following code :

//declare global var countReq

var reqSend=false;

$(document).ready(function(){
    $('#hitme').click(function(){
    if(!reqSend)    {
            $.ajax({
                  type: "POST",
                  url: 'http://jsfiddle.net/',
                }).success(function(res) {
                    $("#a").insert("<p>success</p>");
                }).error(function(res) {
                    $("#a").insert("<p>error</p>");
                });
reqSend=true;
}
    });
});

Upvotes: 1

Related Questions