Welcome Guest, Not a member yet? Register   Sign In
Show page "loading"
#1

I have a SPA-type system that uses adminlte .css, in one method I load several SQL selects to create a page with several tabs of information. I would like to show a loading before assembling the page. I created a simple page to be set up before calling MODELS. But the page is not shown before, it is only shown after SELECT-SQL processing.
PHP Code:
public function trazer_alunosdaturma($ncodtur=null) {
//I tried to put it here
        //$this->load->view('includes/html_header');
       //$this->load->view('includes/menupermissoesadmlte');
       //$this->load->view('v_notasturmax',$dados);
       //$this->load->view('loading');
       //$this->load->view('includes/html_footer');  
  
        $this
->load->model('Notasturma_model','notasturma');    
        $dados
["notasturma"] = $this->notasturma->getfetchalunosdaturma($ncodtur); 
        $dados["disciplinasturma"] = $this->notasturma->getfetchdisciplinasdaturma($ncodtur);
        $dados["professorturma"]=$this->notasturma->getfetchprofessoresdaturma($ncodtur);
        $dados["professores"]=$this->prof->getallprof();
        $retornoinsert=$this->notasturma->montarlistaalunosmapao($ncodtur);
        if ($retornoinsert=0)
        {
            // erro , preciso resolver mensagem de erro e não ir a frente
        }else{
          
            $dados
['mapao']=$this->notasturma->abastecertbmapao($ncodtur);
            $this->load->view('includes/html_header');
            $this->load->view('includes/menupermissoesadmlte');
            $this->load->view('v_visaodaturma',$dados);
            $this->load->view('includes/html_footer');    
        
};
        
        
    

Reply
#2

php can't work like that. for the "loader" you need to show HTML and then make a request to the controller where SQL (in response to JSON or html). Next, you insert tabs in the background and disable the loader
Reply
#3

(11-03-2023, 07:27 AM)ozornick Wrote: php can't work like that. for the "loader" you need to show HTML and then make a request to the controller where SQL (in response to JSON or html). Next, you insert tabs in the background and disable the loader

Thanks for the answer. Notice in the code I posted, I placed the html before loading the methods in the MODELS to show the loading page. But it did not work.

PHP Code:
//I tried to put it here
      //$this->load->view('includes/html_header');
      //$this->load->view('includes/menupermissoesadmlte');
      //$this->load->view('v_notasturmax',$dados);
      //$this->load->view('loading');
      //$this->load->view('includes/html_footer');  
  die();


I put a die() after mounting the last view html_footer.php but the page was blank and I don't know why 
Reply
#4

(This post was last modified: 11-03-2023, 09:27 AM by ozornick.)

I can't tell you exactly what the error is. But the logic is this: Show the base page with the loader (for example, trazer_alunosdaturma()) after doing AJAX to trazer_alunosdaturma_data() and insert the data. If you don't see the commented template, find the error. In general, everything is correct.

And before die() you write $this->load->view('v_notasturmax',$dados); but $dados not installed
Reply
#5
Video 
(This post was last modified: 11-03-2023, 10:12 AM by RRIOS.)

(11-03-2023, 09:25 AM)ozornick Wrote: I can't tell you exactly what the error is. But the logic is this: Show the base page with the loader (for example, trazer_alunosdaturma()) after doing AJAX to trazer_alunosdaturma_data() and insert the data. If you don't see the commented template, find the error. In general, everything is correct.

And before die() you write $this->load->view('v_notasturmax',$dados); but $dados not installed

Yes yes, of course. This line is commented out during testing.
https://youtu.be/P6g0i50Kxns

Code:
$this->load->view('includes/html_header');
$this->load->view('includes/menupermissoesadmlte');
//$this->load->view('v_notasturmax',$dados);
$this->load->view('loading');
$this->load->view('includes/html_footer'); 
Reply
#6

Try sample template. Your loader template incorrect.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div>Loading with JS...</div>
<div style="display: none;">
    <div id="tab1"></div>
    <div id="tab2"></div>
    <div id="tab3"></div>
    <div id="tab4"></div>
</div>
<script>
    /** Ajax code here */
    fetch('/trazer_alunosdaturma/1234')
    .then(
        /** Get SQL data, Insert HTML in promise, close loader */
    )
    .catch(...);
</script>
</body>
</html>
Reply
#7

(11-03-2023, 11:28 AM)ozornick Wrote: Try sample template. Your loader template incorrect.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div>Loading with JS...</div>
<div style="display: none;">
    <div id="tab1"></div>
    <div id="tab2"></div>
    <div id="tab3"></div>
    <div id="tab4"></div>
</div>
<script>
    /** Ajax code here */
    fetch('/trazer_alunosdaturma/1234')
    .then(
        /** Get SQL data, Insert HTML in promise, close loader */
    )
    .catch(...);
</script>
</body>
</html>
Code:
"Your loader template incorrect."
Well, I don't understand what that means.
This is wrong ?
Controller - Start Method + Call to Methods in Models + Call of Views - End Method
Reply




Theme © iAndrew 2016 - Forum software by © MyBB