Wednesday, 7 August 2013

jquery ajax - click event doubling

jquery ajax - click event doubling

I am new to jquery and ajax.
I have a navigation button which I click and it runs some php code.
Problem is each time I click the button, it runs the code more times than
the last time. so click 1: runs code once. click 2: 2 times click 3: 4
times click 4: 8 times!
Here is the jquery code. I don't know if the problem is here or somewhere
else. Thanks in advance..
$('#loa_pending_nav').click(
function() {
var display_type = "Pending";
$.ajax({
type:"POST",
url:'loa_display.php',
statusCode: {
404: function() {
alert('loa_display.php --> NOT FOUND');
}
},
data: "&display_type="+display_type,
success: function(data) {
$('#display').html(data);
}
});
}
);

No comments:

Post a Comment