• How to call AJAX Request on Regular Interval

     




    $(document).ready(function () {
        $(function () {
                 var timer,updateContent;
          function resetTimer() {
            if (timer) {              window.clearTimeout(timer);          }         timer = window.setTimeout(updateContent, 20000);        }     updateContent = function () {         resetTimer();         fetchdata();     };     resetTimer();     }); });
    function fetchdata(){
     $.ajax({
      url: 'fetch_details.php',
      type: 'post',
      success: function(response){
       // Perform operation on the return value
       alert(response);
      }
     });
    }
    
    OR
    function fetchdata(){
     $.ajax({
      url: 'fetch_details.php',
      type: 'post',
      success: function(response){
       // Perform operation on the return value
       alert(response);
      }
     });
    }
    
    $(document).ready(function(){
     setInterval(fetchdata,5000);
    });
  • 0 comments:

    Post a Comment

    FAVOURITE LINE

    To steal ideas from one is plagiarism. To steal from many is Research.

    ADDRESS

    Mumbai , Maharashtra

    EMAIL

    shikha.pathak6@gmail.com
    shikha.the.swt.pari@gmail.com

    Skype

    shikha_pari