title: How push element to array from ajax - jQuery
body: <p>When I try push some element to array and display random element, browser return that array is not define. Where is problem?</p>
  
  <pre><code>var dir = "./images/radovi/";
  var ext = ".png";
  var slike = [];
  $.ajax({
      url: dir,
      success: function (data) {
          $(data).find("a:contains(" + ext + ")").each(function () {
              var ime_slike = this.href.replace(window.location.host, "").replace("http:///", "");
              slike.push(dir + ime_slike + ext);
          });
      }
  });
  $('&lt;img src="' + slike[Math.floor(Math.random() * slike.length)] + '"&gt;').appendTo('#radovi');
  </code></pre>