IE not showing jquery append() images

Posted by Johannes Ruuska on Stack Overflow See other posts from Stack Overflow or by Johannes Ruuska
Published on 2010-04-22T09:16:19Z Indexed on 2010/04/22 9:53 UTC
Read the original article Hit count: 180

Filed under:
|
|
|
|

Ok, so i took John Raasch's slideshow script and modyfied it too dynamicly fetch images from folders on the server through ajax. The slideshow work like a charm in FF and Chrome but IE is not showing the images. And since IE's javascript debugging possibilities is close to none I cant figure out what is crashing.

Javascript (indenting got messed up when pasting here but you get the code anyway):

function slideSwitch() {
var $active = $('#box_bildspel IMG.active');

if ( $active.length == 0 ) $active = $('#box_bildspel IMG:last');

var $next =  $active.next().length ? $active.next()
    : $('#box_bildspel IMG:first');

$active.addClass('last-active');

$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
    });
     }
$(document).ready(function(){
$.get('includes/bildspel.php?page='+page, function(r){
    var file = r.split('!');
    var path = 'pic/bildspel/'+page+'/';
    var data = '';

    if(file != null && file != ''){
        $.each(file, function(key, value){
            if(key == 0) {
                $('#box_bildspel').append('<img src="'+path+value+'" class="active"></img>');
                //console.log(path+value);
            } else {
                $('#box_bildspel').append('<img src="'+path+value+'"></img>');
                //console.log(path+value);
            }
        });
    }


    if(file.length > 1){
        $(function() {
            setInterval( "slideSwitch()", 4000 );
        });
    }

});

});

PHP:

<?php
    function getimgs($page) {

         $path = '../pic/bildspel/'.$page;
         $files = '';

         if ($handle = opendir($path)) {
            while (false !== ($file = readdir($handle))) {
                if ($file !== '.' && $file !== '..') {
                       $files .= $file.'!';
                }
            }
            closedir($handle);

            echo substr_replace($files ,"",-1);;

          }
     }

     getimgs($_GET['page']);
  ?>

Tested in IE 7 & 8

Any ideas? I have a deadline on this site for tomorrow (april 23) would appreciate VERY much if someone could figure this on out for me, thanks in advance!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about append