Evan
Evan

Reputation: 6115

jquery img tag getting removed after it is added using append

On my website I tried to append my image using ("#report-type").append($img) where img is a jquery object with a src website included, based upon a drop down menu selection changing the src of the img. I know that it actually appends in the right place, the img tag is properly formatted, and that the image shows up if i just hardcode the img tag into the HTML.

however, what happens is the page runs, and I see in firebug that the img is appended for a split second and then it disappears. Does anyone have any idea why this might be happening?

here is my function for the dropdown change handler:

    $(".update-report").click(function () {
        var src, image, $img2, val;

        //Clear old charts
        //$("#report-type option").children().remove();

        //alert(typeof $("select option:selected").val());

        val = $("select option:selected").val();
        switch (val[0]) {
            case "0":
                src = "https://graphite.admarketplace.net:2222/render/?from=-7days&width=1400&height=420&_salt=1309990757.707&target=alias(movingAverage(divideSeries(sumSeries(*.server.xml.*.revenue)%2CsumSeries(*.server.xml.*.clicks)),200),%22CPC%22)&fgcolor=black&bgcolor=white&title=Average%20CPC%20per%20minute%20-%207%20Days&hideLegend=true";

                $("#chart1").attr('src',src);
                break;

            case "1":
                alert("here1");
                src = "http://graphite.admarketplace.net:2222/render/?from=-30days&width=1400&height=420&_salt=1309990757.707&target=alias(movingAverage(divideSeries(sumSeries(*.server.xml.*.revenue)%2CsumSeries(*.server.xml.*.clicks)),200),%22CPC%22)&fgcolor=black&bgcolor=white&title=Average%20CPC%20per%20minute%20-%2030%20Days&hideLegend=true";
                $img = createImg(src);
                alert(typeof $img);
                $("#report-type").append($img);
                break;

            case "2":
                alert("here2");
                src = "http://graphite.admarketplace.net:2222/render/?from=-1hour&width=1000&height=400&_salt=1309980469.069&target=alias(e.network.lb.xml.AverageRespTime,%22East%22)&target=alias(w.network.lb.xml.AverageRespTime,%22West%22)&yMax=500&fgcolor=black&bgcolor=white&title=Average%20Response%20Time%20in%20milliseconds%20Current%20Hour";
                $img = createImg(src);
                src = "http://graphite.admarketplace.net:2222/render/?from=-25hour&until=-24hour&width=1000&height=400&_salt=1309980469.069&target=alias(e.network.lb.xml.AverageRespTime,%22East%22)&target=alias(w.network.lb.xml.AverageRespTime,%22West%22)&yMax=500&fgcolor=black&bgcolor=white&title=Average%20Response%20Time%20in%20milliseconds%20Current%20Hour%20Yesterday";
                $img2 = createImg(src);

                $(".grid 16").append($img);
                $(".grid 16").append($img2);
                break;

            case "3":
                alert("here3");
                src = "http://graphite.admarketplace.net:2222/render/?from=-1day&width=1000&height=400&_salt=1309980469.069&target=alias(movingAverage(e.network.lb.xml.AverageRespTime,20),%22East%22)&target=alias(movingAverage(w.network.lb.xml.AverageRespTime,20),%22West%22)&yMax=500&fgcolor=black&bgcolor=white&title=Average%20Response%20Time%20in%20milliseconds%20Current%2024%20Hours";
                $img = createImg(src);
                src = "http://graphite.admarketplace.net:2222/render/?from=-2day&until=-1day&width=1000&height=400&_salt=1309980469.069&target=alias(movingAverage(e.network.lb.xml.AverageRespTime,20),%22East%22)&target=alias(movingAverage(w.network.lb.xml.AverageRespTime,20),%22West%22)&yMax=500&fgcolor=black&bgcolor=white&title=Average%20Response%20Time%20in%20milliseconds%20Yesterday";
                $img2 = createImg(src);

                $(".grid 16").append($img);
                $(".grid 16").append($img2);
                break;
                default:
                    alert("in the default");
        }
    });

Just pay attention to case 0 here because I've been fooling around trying to get this to work. This does not work either, even when I hardcode an img tag into the HTML and ONLY try and change the src. However when I try and append the whole image this doesn't work either.

Upvotes: 1

Views: 180

Answers (1)

Andy
Andy

Reputation: 30135

I'm suspecting you have some kind of adblocker which removes the image since the src is admarketplace...

We once spent an evening on a similar problem with a "banner.jpg" image :)

Upvotes: 1

Related Questions