In general, I want to realize the output of the image after it is loaded on the page without reloading. At the moment I can display data about the file loaded or the text required. Can you tell me how to get the output of several images with JSON after downloading?
Js
$(function(){ $('#my_form').on('submit', function(e){ e.preventDefault(); var $that = $(this), formData = new FormData($that.get(0)); $.ajax({ url: $that.attr('action'), type: $that.attr('method'), contentType: false, processData: false, data: formData, dataType: 'json', success: function(json){ if(json){ $that.replaceWith(json); } } }); }); });<br> Php
if(isset($_POST['fio'],$_FILES['avatar'])){ $req = false; ob_start(); echo '<pre>'; echo 'Имя пользователя: <strong>' , $_POST['fio'] , '</strong><br>Данные загруженного файла:<br>'; print_r($_FILES['avatar']); echo '</pre>'; $req = ob_get_contents(); ob_end_clean(); echo json_encode($req); exit; }
img src="ссылка"- Vasily Barbashevechooutput beforeecho json_encode($req)- Vasily Barbashev