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