doushishi6513 2015-02-03 20:26
浏览 52

使用控制台从codeigniter中执行javascript

I want to execute a dom ready javascript function from within codeigniter, I know how to do it -regular and usual way- using a view, but now I need to do it using the console, as when you usually run a php index.php controller method parameter_A parameter_B... from the console, my javascript function itself contains an ajax function as part of its definition, i.e.

<script type="text/javascript">
    $(document).ready(function() {
    function envia_mail_ajax(numero, form_data,ruta){   
    var iddiv="#mail_"+numero;
    window.setTimeout( 
    function(){
    $.ajax({
        url: "<?php echo site_url('emailmasivo'); ?>/" +ruta+ "/" +numero, 
        cache: false,
        type: 'POST',
        data: form_data,
        dataType: "json",
        success: function(html){
            $( iddiv ).append(html.mensaje+"
"+'<br />');
        }   
    });
}, 600);    
}
    var hola="hola";
    var cuenta_id=<?php echo $id_cuenta; ?>;

    <?php 
        echo $lista_mails;
    ?>

    if( correos_e.length==0)
        window.close();
    j=0;
    for (i=<?php    echo $ini;  ?>; i<(correos_e.length);i++){
        if ( correos_e[i] != undefined ){
            j=j+1;
            str_tmp = '<div id="mail_'+i+'">'+correos_e[i]+
                    '<img src="<?php echo base_url();?>images/ajax-loader.gif"  />'+'</div>'+"
";
            console.log(str_tmp);
            $('#resultado_envio').append( str_tmp );
            envia_mail_ajax(i,
    {para:correos_e[i],id_masivos:id_masivos_e[i],id_mat_referencia:id_mat_referencia_e[i],
            id_tipouser:id_tipouser_e[i],nombre:nombres_e[i], sexo:sexos_e[i], matricula:matriculas_e[i], passa:passa_e[i],id_cuenta:cuenta_id},
                "<?php echo $r_ajax; ?>");              
        }
    }
});
</script>

as you can see, there´s no problem in using a view (this code is located in a view!), but, how can make the javascript run when using the console to run the whole program using the same controller, method and parameters used in the browser-view version? thanx i.a.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog