0

im getting a little issue here. Im trying to load an image, but seems it isnt correct. Im getting the data of image, but i just want to load it instead of.

Whats wrong?

var url = $(this).find("img").attr("ref");

$("#produto .main-photo .photo img").load(url, function() {

                    $("#produto .main-photo .loader").fadeOut();
                    $("#produto .main-photo .photo").fadeIn();

});

3 Answers 3

1

You should not use load for this. Simply set the src of the image:

$("#produto .main-photo .photo img").attr("src",url);

load is used to make an AJAX call.

Sign up to request clarification or add additional context in comments.

2 Comments

Then how can i preload the image?
Just search for jquery preload images, I'm sure that question has been asked many times.
0

$('<img/>')[0].src = yoururl;

Comments

0

It might make more sense to just use an img tag, dynamically sourced and faded in:

var img = $("#produto .main-photo .photo img");
var url = $(this).find("img").attr("ref");

img.fadeOut();
img.attr('src', url);
img.fadeIn();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.