$("#classesLink").click(function(event) {
$("#globalUserContent").children().slideUp("normal", function() {
$.ajax({
type: "POST",
url: "classes.php?token="+randString+"",
success: function (msg) {
$("#globalUserContent").html(msg);
},
error: function (msg) {
$("#globalUserContent").html(msg);
}
});
});
return false;
});
I have the above code and when i click the .classesLink button and check the firebug requests, it shows that it is being submitted twice, is there anything wrong with it?
As noted by @am not I am.
$("#globalUserContent")has two childrens so the callback fires twice one for each child, use this:This will execute the callback- ajax requst, when the
slideUpeffect is finished, And doesn’t hardcode thesetTimeoutdelay in the code.If you hardcode
600in the code, the code could break if the"normal"duration will change some day, or someone changed theslideUpduration effect but didn’t change the timeout delay.But you can put the duration-delay in a variable so you change it in one place – @am not I am suggestion.
whendocs: