Search code examples
javascriptjquerypluginscountdown

Jquery Countdown Redirect


I want to redirect my page as soon as the countdown turns (the end date and current date is same). I have been using a Jquery Plugin that is beautiful but they have not mentioned the callback function to do so. Now I have to pass function to the Jquery Plugin Can someone help me on how to pass function while calling the plugin. This is my code

$('.countdown').final_countdown({
    'start': <?php echo  $today; ?>,
    'end': <?php echo $date1; ?>,
    'now': <?php echo  $today; ?>,
                    seconds: {
        borderColor: 'rgba(0,153,102,1)',
        borderWidth: '15'
    },
    minutes: {
        borderColor: '#ACC742',
        borderWidth: '15'
    },
    hours: {
        borderColor: '#ECEFCB',
        borderWidth: '15'
    },
    days: {
        borderColor: 'rgba(0,153,102,1)',
        borderWidth: '20'
        },callback : functions(){
            'alert("Hie")'      

        }
        //  if('end' >= 'start')
        //$("body").load(retreive.php?<?php //echo $_GET['g']?>)
});

Solution

  • Assuming that you are using this plugin, then the second argument when calling it is the callback function to execute on completion of the countdown:

    $('.countdown').final_countdown({
        start: <?php echo  $today; ?>,
        end: <?php echo $date1; ?>,
        now: <?php echo  $today; ?>,
        seconds: {
            borderColor: 'rgba(0,153,102,1)',
            borderWidth: '15'
        },
        minutes: {
            borderColor: '#ACC742',
            borderWidth: '15'
        },
        hours: {
            borderColor: '#ECEFCB',
            borderWidth: '15'
        },
        days: {
            borderColor: 'rgba(0,153,102,1)',
            borderWidth: '20'
        }
    }, function() {
        console.log('countdown completed');
        // Do something...
    });