Hi.
Below is some code that I am working on which upon a sucessful result displays a lightbox. The problem I am having is that bit code that fires the light box seems to trigger multiple times causing everything to flicker etc while it sorts itself out.
Looking in Firebug I can see that the lightbox was fired at least 40 times.
The only thing I think it might be is the time out function however I am not sure how to fix this at all.
Sorry for the lay out of the js as well, it not easy to format!!
Cheers Chris
function bookWebinar(webinarId,tafUrl)
{
$.post("my_content/gtw/webinarProcess.php", {wid: webinarId,bookWebinar:1},
function(data)
{
var obj = jQuery.parseJSON(data);
if(obj.result=="failure")
{
//show the message in the div with a red background
$(".bookingResult").addClass("classroomExpertError");
$(".bookingResult").html(obj.Message);
$('.bookingResult').show('slow', function()
{
setTimeout(function(){$('.bookingResult').hide('slow');},3000);
});
}
else
{
//show the message in the div with a green background
$(".bookingResult").addClass("classroomExpertSuccess");
$(".bookingResult").html(obj.Message);
$('.bookingResult').show('slow', function()
{
setTimeout(
function(){
$('.bookingResult').hide('slow',
function()
{
//need to put the taf form in here
$.colorbox({href:"my_content/taf.php?tafUrl="+tafUrl,
onClosed: function (message) {
window.location.replace("my_content/opening-offer.php");
}
});
});},3000);
});
}
});
return false;
}