Bring images with ajax

0

It is the following personal, I was able to store the links of the images in the database and also stored those images in a folder of my computer. so I wanted to know how I can get these images with javascript and play them on my site. I would like to use this link in the bank and get the link from it, with this link I wanted to be able to play on my page from the java script, I am getting these links with ajax , just not I know how to move the image to the site, the description I got, how do I do it?

$(document).ready(function(){

 var imageName;
 
   var postagens = function(){
		

		$('#retorno').empty();		

		$.ajax({
			method : 'GET',
			url :'postagens.php',
			dataType : 'json',
			complete: function(dados){

					response = dados.responseJSON;

					for(var i = 0 ; response.length > i; i++){
					//document.getElementById("retorno").innerHTML = response[i].descricao;
					$('#retorno').append('<p>'+ response[i].descricao +'</p> <br>');
					

					}

			} 

		});
}

   

});
</div>

            <div>
                    <form id="conteudo" >

                         <div class="form-group">
                                <label for="exampleTextarea"></label>
                                <textarea class="form-control" id="exampleTextarea" rows="3"></textarea>
                        </div>
                            <button type="submit" class="btn btn-primary" id="btnPostar" name="btnPostar" >Postar</button> 
                            <input type="file" name="btnImage" id="btnImage"  class="btnImage" accept="image/*">
                            <hr size="1"> 

                            <p id="retorno"  name="retorno" > </p> <br>
                            <img  id="imagem"  src="">
                            
                    </form>
                
                
              </div>
    
asked by anonymous 08.10.2017 / 13:42

1 answer

0

Following the same idea as you did with the description.

Let's assume your bank return is imagem , you would do so ...

$.ajax({
   type: 'post',
   url: 'SUA URL',
   success: function(data){
      $('#retorno').append('<img src="'+data.imagem+'">');
   }
}) 

In this way, a new image will always be created with the path in the bank.

    
08.10.2017 / 16:27