function fetch_data(pid) {
  var stime = new Date(); // start time

  var sdate = document.getElementById('w0').value;
  var edate = document.getElementById('w1').value;


    //call the url using jquery's ajax
      $.ajax({
       url: 'index.php?r=site/stats&pid=' + pid,
       type: 'get',
       data: { sdate:sdate, edate:edate},
       beforeSend: function(){
        // Show image container
        $("#loader").show();
       },
       fail: function(xhr, textStatus, errorThrown){
           alert('request failed ' + xhr.responseText);
         },
       success: function(response){
         //populate with data
         $("#result").html(response);
          var etime = new Date();
          console.log('stime is ' + stime);
          console.log('etime is ' + etime);
          var interval = (etime-stime); // Difference in milliseconds.
          console.log(interval);
          var totalSeconds = (interval/1000);
          console.log(totalSeconds);
          if (totalSeconds < 60 ) {
            $("#time").html('Query took '+pad(totalSeconds)+' seconds');
          }else {
            $("#time").html('Query took : '+pad(parseInt(totalSeconds / 60))+' minutes : '+pad(parseInt(totalSeconds % 60))+' seconds');
          }
       },
       complete:function(){
        // Hide image container
        $("#loader").hide();
       }
  });
}
//fetch data using ajax call from the url below
fetch data using ajax call from the url below
fetch data using ajax call from the url below
function fetch_data(pid) {
  var stime = new Date(); 
  var sdate = document.getElementById('w0').value;
  var edate = document.getElementById('w1').value;
      $.ajax({
       url: 'index.php?r=site/stats&pid=' + pid,
       type: 'get',
       data: { sdate:sdate, edate:edate},
       beforeSend: function(){
        $("#loader").show();
       },
       fail: function(xhr, textStatus, errorThrown){
           alert('request failed ' + xhr.responseText);
         },
       success: function(response){
         $("#result").html(response);
          var etime = new Date();
          console.log('stime is ' + stime);
          console.log('etime is ' + etime);
          var interval = (etime-stime); 
          console.log(interval);
          var totalSeconds = (interval/1000);
          console.log(totalSeconds);
          if (totalSeconds < 60 ) {
            $("#time").html('Query took '+pad(totalSeconds)+' seconds');
          }else {
            $("#time").html('Query took : '+pad(parseInt(totalSeconds / 60))+' minutes : '+pad(parseInt(totalSeconds % 60))+' seconds');
          }
       },
       complete:function(){
        $("#loader").hide();
       }
  });
}
function fetch_data ( pid ) { var stime = new Date ( ) ; var sdate = document . getElementById ( 'w0' ) . value ; var edate = document . getElementById ( 'w1' ) . value ; $ . ajax ( { url : 'index.php?r=site/stats&pid=' + pid , type : 'get' , data : { sdate : sdate , edate : edate } , beforeSend : function ( ) { $ ( "#loader" ) . show ( ) ; } , fail : function ( xhr , textStatus , errorThrown ) { alert ( 'request failed ' + xhr . responseText ) ; } , success : function ( response ) { $ ( "#result" ) . html ( response ) ; var etime = new Date ( ) ; console . log ( 'stime is ' + stime ) ; console . log ( 'etime is ' + etime ) ; var interval = ( etime - stime ) ; console . log ( interval ) ; var totalSeconds = ( interval / 1000 ) ; console . log ( totalSeconds ) ; if ( totalSeconds < 60 ) { $ ( "#time" ) . html ( 'Query took ' + pad ( totalSeconds ) + ' seconds' ) ; } else { $ ( "#time" ) . html ( 'Query took : ' + pad ( parseInt ( totalSeconds / 60 ) ) + ' minutes : ' + pad ( parseInt ( totalSeconds % 60 ) ) + ' seconds' ) ; } } , complete : function ( ) { $ ( "#loader" ) . hide ( ) ; } } ) ; }
fetch data using ajax call from the url below
fetch data using ajax call from the url below
// start time //call the url using jquery's ajax // Show image container //populate with data // Difference in milliseconds. // Hide image container