Good day, guru, please tell me how to display for example 4 images on the screen, here is the original:

<script src="http://www.google.com/jsapi"></script> <script type="text/javascript"> // Подключение jQuery google.load('jquery', '1.4.2'); google.setOnLoadCallback(function() { var image_key=encodeURIComponent('Купить слона'); function getimage(id) { $('#img1')['attr']('src', 'http://www.ajaxload.info/images/exemples/26.gif'); $['getJSON']('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=' + image_key + '&rsz=2&imgsz=medium&callback=?', function (json) { $('#img1')['attr']('src', (json['responseData']['results'][id]['url'])); $('#img1')['error'](function () { getimage(id + 1); }); }); }; getimage(0); }); </script> <img id="img1" width="100" alt="[KEY]" title="[KEY]"> <br /> 

Here is my attempt (please don't kick with your feet):

 <script src="http://www.google.com/jsapi"></script> <script type="text/javascript"> // Подключение jQuery google.load('jquery', '1.4.2'); google.setOnLoadCallback(function() { var image_key=encodeURIComponent('Купить слона'); for (j=1; j<=4; j++) function getimage(id) { $('#img' + j)['attr']('src', 'http://www.ajaxload.info/images/exemples/26.gif'); $['getJSON']('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=' + image_key + '&rsz=4&imgsz=medium&callback=?', function (json) { $('#img' + j )['attr']('src', (json['responseData']['results'][id]['url'])); $('#img' + j )['error'](function () { getimage(id + 2); }); }); }; getimage(0); }); </script> <?php for ($i = 0; $i<4; $i++) { echo '<img id="img'.$i.'" width="100" alt="[KEY]" title="[KEY]">'; } ?> 

Here is

  • the original of what? what to bring? in an ancient version could not find jQuery? - zb '
  • 2
    so what? - zb '
  • Thanks for the solution, but you can use javascript to get only links to images and HTML to display them like this (for example, 4 pictures): <img id = "img1" src = "REFERENCE TO IMAGE_1.jpg" title = "" alt = "" /> <img id = "img2" src = "LINK TO IMAGE_2.jpg" title = "" alt = "" /> <img id = "img3" src = "LINK TO IMAGE_3.jpg" title = "" alt = "" /> <img id = "img4" src = "REFERENCE TO IMAGE_4.jpg" title = "" alt = "" /> - srazil
  • @eicto, they could not find any more decent images!? - AseN
  • @srazil - and you get src, look at the results object in the console, everything is there. @Francesco since when are these images not adequate? youtu.be/T-TA57L0kuc - zb '17

0