php – GetJSON and Request-ThrowExceptions

Exception or error:

I wish to be able to deliver a new variable to my getJson and make a $ _REQUEST to my php file which has caused me problems since I can’t get the new field it is possible to send a folder path variable through this json I leave code. My new variable is branch.

lista.html

    function verdoc(branch,id,pag,texto){


             $('#prev').unbind();
             $('#sig').unbind();
             $( "#visor_body" ).html("<img src='images/ajax-loader.gif' alt='Cargando...'>");
             $( "#visor" ).dialog({ title:texto, position: ['center','top'], modal : true,width:700, height:550,resizable:false });

              $.getJSON('visor.php?branch='+branch+'&id='+id+'&pag='+pag, function(data){ 
                       $('#prev').unbind().click(function (){verdoc(id,data.prev,texto);return false;});
                       $('#sig').unbind().click(function (){verdoc(id,data.next,texto);return false;});
                       if(parseInt(data.next)>=parseInt(data.total)){$('#sig').unbind();}
                       if(parseInt(data.prev)<0){$('#prev').unbind();}
                       $('#paginas').html(parseInt(parseInt(data.pag)+1)+" de "+data.total);
                       $('<img />')
                       .attr('src', 'pdoc.php?'+data.src+'&ids='+Math.random()).bind('contextmenu', function(e){
                            return false;
                        })
                        .load(function(){
                            $('#visor_body').html( $(this) );
                            // Your other custom code
                        });
                       //$( "#visor_body" ).html("<img src='pdoc.php?"+data.src+"'>");

                    });
 <form method="post" action="{{url_post}}">
                                                <input type="hidden" name="descripcion" value="NĂºmero de parte : {{item.numero_parte}}, Juzgado:{{item.juzgado}}, Unidad Policial : {{item.unidad_policial}} "> 
                                            {%for itemdoc in item.lista_documentos%}
                                                  <p><a id="link" href="#mid" onClick="verdoc('{{itemdoc.branch}}','{{itemdoc.document_revision_id}}','0','<span style=\' font-size:14px;\'>Parte : {{item.numero_parte}}, {{itemdoc.fecha_entrega}}</span>');" class="ui-button ui-widget ui-state-default ui-corner-all"><span class="ui-icon ui-icon-document"></span></a> Documento enviado: {{itemdoc.fecha_entrega}},&nbsp{{itemdoc.branch}}&nbsp;<input type="checkbox" name="urls[]" value="{{itemdoc.document_revision_id}}"></p>       
                                            {%endfor%}  

visor.php

    <?php
require_once('seguridad.php');
require_once ('BptCdcClient.php');
$BptCliente=new BptCdcClient(WEB_SERVICE_URL);
$BptCliente->sessionId=$_SESSION['_ID_'];

if ($BptCliente->isAuth()){
function getNumPagesPdf($filepath){
    $fp = @fopen(preg_replace("/\[(.*?)\]/i", "",$filepath),"r");
    $max=0;
    while(!feof($fp)) {
            $line = fgets($fp,255);
            if (preg_match('/\/Count [0-9]+/', $line, $matches)){
                    preg_match('/[0-9]+/',$matches[0], $matches2);
                    if ($max<$matches2[0]) $max=$matches2[0];
            }
    }
    fclose($fp);
    if($max==0){
        $im = new imagick($filepath);
        $max=$im->getNumberImages();
    }

    return $max;
}
    if(file_exists('../dockeyst-cdc/upload/'.$_REQUEST["branch"].'/'.$_REQUEST["id"])){
        $num=getNumPagesPdf('../dockeyst-cdc/upload/'.$_REQUEST["branch"].'/'.$_REQUEST["id"]);
        $src="ids=".  rand(1000000000000000000000, 99999999999999999999999999)."&id=".$_REQUEST['id']."&pag=".$_REQUEST['pag'];
        $prev=$_REQUEST["pag"]-1;
        $next=$_REQUEST["pag"]+1;
        $arr["total"]=$num;
        $arr["src"]=$src;
        $arr["estado"]="OK";
        $arr["pag"]=$_REQUEST['pag'];
        $arr["prev"]=$prev;
        $arr["next"]=$next;
        ob_clean();
        echo json_encode($arr);
    }
}
?>

The branch variable is empty, so I cannot search the folder path, this value would be the following 2020/02

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *