I am trying to download (into memory) an image as an object firstm, and display it as a background of body.
here is what I have done:
var url = "www.example.com/image/image.jpg";
var imageObject;
$.ajax({
type: "GET",
url: url,
datatype:"image/jpg",
success: function (data) {
imageObject = data;
$("body").css("background", imageObject); // not working
//$("body").css("background", "url("+url+")"); //same image data from the memory?
}
});
I am pretty sure there is no problem on displaying an image on <img> tag in this way by changing src attr.
But how can I change the background using image object?
If I just put same url in to the background, will that be using same image data from the memory?