Pass value to 2 different paths

0

I would like to pass the var data = 'codreq =' + id; variable to two paths. It is possible? If so, someone can teach me. I can only move to this path:

url: "<?= base_url('coordenador/protocolo/buscaDetalhesRequerimento') ?>"

I need to pass this one at the same time:

url: "<?= base_url('coordenador/protocolo/responder_requerimento') ?>"



<script>
$(document).ready(function ()
{
    $("a#visualizar").click(function () {
        var id = $(this).attr('data-id');
        var data = 'codreq=' + id;
        //alert(data);
        $.ajax({
            type: "POST",
            url: "<?= base_url('coordenador/protocolo/buscaDetalhesRequerimento') ?>",
            data: data,
            success: function (text) {
                //if (text === "success") {
                $(".dados").html(text);
                //  });
                //window.location.reload(true);
                //}
            }
        });


    });
});

    
asked by anonymous 08.02.2017 / 20:18

1 answer

0

Sending the same data to two or more concurrent requests :

<script>
$(function () {
    $("#visualizar").click(function () {
        var id = $(this).attr('data-id');
        var url1 = '<?= base_url('coordenador/protocolo/buscaDetalhesRequerimento') ?>';
        var url2 = '<?= base_url('coordenador/protocolo/responder_requerimento') ?>';
        $.when(
            $.post(url1,{codereq:id},function(text) {
                console.log(text);
                $(".dados").html(text);
            }),
            $.post(url2,{codereq:id},function(resp2) {
                console.log(resp2);
            })
        )
    });
});
</script>
    
09.02.2017 / 02:42