JSFiddle - React, Tailwind, and code Playground

by Qwerty_Wasd

HTML

<input id="focusedInput" value="сиськи" >
<button type="submit" id="find-file">Поиск</button>
  
<img id="imgbook" width="200" src="http://javascript.ru/forum/images/smilies/smile.gif">

JavaScript

$(function(){
  $('#find-file').click(function(){
    getimage(0, encodeURIComponent($('#focusedInput').val()));
  });
 
  function getimage(id, image_key) {
     $('#imgbook')['attr']('src', './progress.gif');
     $['getJSON']('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=' + image_key + '&rsz=2&imgsz=medium&callback=?', function (json) {
         $('#imgbook')['attr']('src', (json['responseData']['results'][id]['url']));
         $('#imgbook')['error'](function () {
             if(json['responseData']['results'][++id]) getimage(id, image_key); //проверка, чтоб небыло бесконечного цикла
         });
     });
  };
});