0

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?

Edited by 9tontruck

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by JorgeM
0

What data are you sending from the server back to the client? Also, you'll find that to actually get to the data, you should be referencing data.data in your case.

You can know for sure if you use your browser's dev tools (in chrome and IE hit F12) and analyze the data from the server.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.