Ajax call every minute using jQuery

As of these days most social networking sites are using this event to load most recent posts every second without refreshing page, stream and tweets like Facebook, Google+ and Twitter, it loads in the top part of the page. they are using latest technology like node.js and many more to reduce server load. you can also do same using a AJAX for your own purpose.

You may also like How to Interval Timer Countdown using setTimeout() and How to get Page Loading Time using PHP.

Jquery Code

<script type="text/javascript">
    var i = 60;
    var myVar;
    function onTimer() {
        if (i < 0)
        } else
            myVar = setTimeout(onTimer, 1000);

    function getQuizinformation()
        var formData = new FormData();
        var contact = $('#QuestionQuiz').serializeArray();
        $.each(contact, function (key, input) {
            formData.append(input.name, input.value);

            type: 'POST',
            url: "submitquiz.php",
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            success: function (data) {
                i = 60;
                if (data.studentflag == 1)

Leave a Reply

Your email address will not be published. Required fields are marked *