Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
Created August 24, 2013 18:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sTiLL-iLL/6329826 to your computer and use it in GitHub Desktop.
Save sTiLL-iLL/6329826 to your computer and use it in GitHub Desktop.
ajaxn - ified image preloader... its gewd!
(function() {
var f = [];
$.ajax({
url: "imgz.js",
type: "GET",
contentType: "json",
cache: true,
success: function(data) {
var j = JSON.parse(data);
var $c = $("#container");
for (var x = 0; x < j.length; x++) {
var imag = document.createElement("img");
imag.src = j[x].src;
$(imag).css("height", "100%").css("width", "100%");
f[x] = imag;
$c.append(imag);
}
return f;
},
error: function(jqXhr, textStatus, error) {
alert("ERROR: " + textStatus + ", " + error);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment