How do I visualize the image

1

I was wondering how I could show an image in a form that shows information of the fields of a table depending on its id, I am not saving the image in itself, but the address of the folder where I have saved the image.

and I would like to show it in the form, either with a hyperlink tag or with the img tag, but I do not know how. I use Ajax to show the fields in the form.

  function Tinv(id){
  $.ajax({
    type:"POST",
    data:{'id':id},
    dataType:'json',
    url: uri + "/inventario/mostrarInv",
  }).done(function(respuesta){

    $("#id").val(respuesta.id);
    $("#ubicacioni").val(respuesta.ubicacion);
    $("#asignadoi").val(respuesta.asignado);
    $("#subcategoriai").val(respuesta.subcategoria);
    $("#estadoi").val(respuesta.estado);
    $("#actividadi").val(respuesta.actividad);
    $("#sistemaoi").val(respuesta.sistemao);
    $("#marcai").val(respuesta.marca);
    $("#modeloi").val(respuesta.modelo);
    $("#seriali").val(respuesta.serialp);
    $("#placai").val(respuesta.placa);
    $("#serialcargadori").val(respuesta.serialcargador);
    $("#serialbateriai").val(respuesta.serialbateria);
    $("#velocidadprocesadori").val(respuesta.velocidadprocesador);
    $("#rami").val(respuesta.ram);
    $("#discoduroi").val(respuesta.discoduro);
    $("#ipi").val(respuesta.ip);
    $("#lani").val(respuesta.lan);
    $("#wlani").val(respuesta.wlan);
    $("#activirusi").val(respuesta.antivirus);
    $("#observacionesi").val(respuesta.observaciones);
    $("#licenciaos").val(respuesta.licenciaos);



    $("#modalInv").modal();

  }).fail(function(r){
    alert(r);
  });
}

with this javascript code I show the fields that are stored in the database by the id.

Then I do not know how I could show the image with the address stored in the database, since I show the information of each of the fields correspond to a row in the bd.

    
asked by JOHAN ALEXIS MORENO GUISAO 14.11.2018 в 20:35
source

2 answers

1

You can do it by changing the src attribute of an img element with jquery like this:

<img id="imagen" src="">

$("#imagen").attr("src", respuesta.licenciaos);

I hope it serves you.

    
answered by 14.11.2018 / 20:43
source
0

Instead of putting it that way $("#licenciaos").val(respuesta.licenciaos); , try this .. $("#licenciaos").src "direccion de ubicacion" + respuesta.licenciados;

I'll leave this for you to guide yourself better.

document.getElementById('imagenEditar').src = "http://localhost/WareHouse/assets/img/" + image;
    
answered by 14.11.2018 в 20:43