Codeigniter read session value from a controller in the view - Percentage of progress

0

I have the following code in a view:

function getstatus(){
base_url = '<?=base_url()?>';
var percentage;
      $.ajax({
          url: base_url+"teleinforme/getstatus",
          type: "POST",
          dataType: 'json',
          success: function(data) {
            alert(data.status);
            if(data.status=="pending"){
              percentage=(data.count/data.size)*100 + '%';
              $('#percentage').text(percentage);
              setTimeout('getstatus()', 1000);
            }
            else{
              alert(data.status);
              $('#percentage').text('100%');        
              $('div#blockUI').hide();
            }
          },
          error: function(data) {
            alert(data.message);
        },
      });
    }

I need to read the value of the session from the controller while it is executing a for each. This is the code in the controller:

foreach ($info_reporte as $key => $tupla) {
$arraydata=array("status"=>"pending","count"=>$count ,"size"=>sizeof($info_reporte));
$this->session->set_userdata('downloadstatus', $arraydata);         
$count++;

 // more code
}

This function is called by the jquery function:

function getStatus()
{
    echo json_encode($this->session->userdata('downloadstatus'));
}

I can not read the value of the session from the getstatus function while setting the session within the for each. Any help is welcome.

    
asked by user2820116 16.11.2017 в 19:45
source

0 answers