4
How would I make a for or any kind of loop showed the result respecting the time of 1 second for example between an iteration and another?
I tried it and it didn’t work:
for( var i=0; i < 10; i++ ){
    setTimeout(function (){console.log('valor de i='+i); },1000);
}
The purpose of these intervals occurs in the following situation:
dup.crtPdf=function(flag){    
    var array = $('#dup-jqxGrid02').jqxGrid('getrows');                          
    dup.arrayCrt = array.slice(0);                                               
    var tempo =0;
    for(var i=0; i<array.length; i++){                                  
            var obj = new Object();                  
            switch (flag){
                case 1: obj.ireport = "/reports/samples/crt_frete_pago_completo"; break; // CASO FOR IGUAL A 1 - FRETE PAGO
                case 2: obj.ireport = "/reports/samples/crt_a_pagar_completo"; break;    // CASO FOR IGUAL A 1 - FRETE À PAGAR
            }            
            obj.parametros = new Array({"id" : dup.arrayCrt.pop().con_id });
            custom.ajax(obj,'registrar',"../relatorios/imprimir.php");
            window.open("../relatorios/imprimir.php");                                          
    }               
};
Print file.php
    <?php    
    /* @author Maison K. Sakamoto
     * Data: 20/09/2013
     * @version 0
     * Arquivo Generico para imprimir quaisquer iport 
     * 
     * COMO USAR:
     * 1º FAZER UMA CHAMADA PARA A FUNÇÃO REGISTRO
     *      DEVERA FAZER UM POST VIA AJAX COM UM OBJETO CONTENDO DOIS PARAMETROS
     *      PARAMETRO 1 - STRING CONTENDO O PATH/NOME DO ARQUIVO.JRXML
     *      PARAMETRO 2 - ARRAY DE PARAMETROS NECESSÁRIOS PARA O JRXML FAZER A CONSULTA NO BANCO DE DADOS
     * 2º NO RETORNO DO AJAX(success) DEVERÁ SER FEITO UM "window.open()" CHAMANDO ESTE ARQUIVO
     */
    include_once 'server/Adl/Configuration.php';
    include_once 'server/Adl/Config/JasperServer.php';
    include_once 'server/Adl/Config/Parser.php';
    include_once 'server/Adl/Integration/RequestJasper.php';
    @session_start();                                                           //ABRE AS VARIAVEIS DE SESSÃO
    @$funcao = $_REQUEST['funcao'];                                             //PEGANDO O NOME DA FUNÇAO 
    is_string($funcao) ? call_user_func($funcao) : imprimir();                  //VERIFICA SE É UM REGISTRO OU IMPRESSÃO    
    function imprimir(){                                                        //FUNÇÃO IMPRIMIR        
        $obj = (object) unserialize($_SESSION['obj']);                          //PEGANDO DA SESSION E PARSE EM OBJECT                
        $jasper = new Adl\Integration\RequestJasper();                          //INSTANCIA DA API JASPERSERVER        
        header('Content-type: application/pdf');                                //CABEÇALHO SETANDO TIPO PDF
        echo $jasper->run($obj->ireport,'PDF',$obj->parametros[0]);             //EXECUÇÃO        
    }                                                                           //FIM DA FUNÇÃO IMPRIMIR
    function registrar(){                                                       //FUNCÃO REGISTRA OS PARAMETROS EM SESSÃO
        $_SESSION['obj'] = serialize($_REQUEST['obj']);                         //OBJETO COM ATRIBUTO "IREPORT" E "PARAMETROS"        
        echo json_encode(Array("info"=>"ok"));                                  //RETORNO DE CONFIRMAÇãO DO AJAX        
    }                                                                           //FIM DA FUNÇÃO REGISTRAR        
?>
Namely the custom.ajax(obj,'registrar',"../relatorios/imprimir.php"); makes the record on $_SESSION then I open the print.php file with the window.open("../relatorios/imprimir.php"); so this file becomes generic and can be used several times changing only the parameters in ajax, indicating which iReport will be called
@Danielomine n o m e u c a s I simplified the question just to spare understanding of the purpose, that in my case would shoot ajax to php pages that makes use of $_SESSION that this had not time to record in Ssion, so I focused on the problem that was to fire javascript at intervals, the purpose I’m sure is not duplicated.
– SneepS NinjA