jeudi 19 septembre 2019

How to show img in laravel app using javascript

hello guys i need to help, i working in app laravel for print the badge and the ticket , but have one problem : The image is not showing even if the link is correct (in javascript) but if i added the same image in code html it works very well.

<script>
 function printdiv(divID)
    {
      var nom = document.getElementById('nom').value ;
      var prenom = document.getElementById('prenom').value ;
      var token = $("input[name='_token']").val();
      @foreach($champs as $input)
      var  = document.getElementById('').value ;
      @endforeach


          $.ajax({
              url: "<?php echo route('printform',['id'=> $id]) ?>",
              method: 'POST',
              data: {nom:nom, prenom:prenom, _token:token 
                @foreach($champs as $input)
                    , : 
                @endforeach
              },
              success: function(data) {
                 var qr=document.createElement("img");
                 qr.src="/qrcodes/";
                 document.getElementById('imgq').appendChild(qr);

              $.post('',{"from":"HM43","nom":nom,"prenom":prenom});

              document.all.item(divID).innerHTML ="<h2 style='text-align:center; font-size:50px'>  "+nom+" "+prenom+"<br> </h2>";
              @foreach($champs as $input)
                document.all.item(divID).innerHTML +="<h2 style='text-align:center; font-size:46px'> "++"<br> </h2> "; 
              @endforeach
               document.all.item(divID).innerHTML +="<img src='/qrcodes/' style='width:100PX' />"; 
              var headstr = "<html><head><title></title></head><body  style='width: 350px'>";
              var footstr = "</body>";
              var newstr = document.all.item(divID).innerHTML;
              var oldstr = document.body.innerHTML;
              document.body.innerHTML = headstr+newstr+footstr;
              window.print();
              document.body.innerHTML = oldstr;
              document.all.item(divID).innerHTML = "";
              return false;

              }
          });

    }

</script>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire