2012-05-02 63 views
0

我有外部html,我已经创建了jcorousal(图像通过ajax加载)。但外部页面没有加载在我目前的div:ajax在外部div下不加载

<div class="corousal_content" id="MyDivName"> <!-- External html will load here--> </div> 

这是我的外部网页,其中包括jcarousal:

<script type="text/javascript"> 
alert("load ajax"); 
function mycarousel_itemLoadCallback(carousel, state) 
{ 
    // Since we get all URLs in one file, we simply add all items 
    // at once and set the size accordingly. 
    if (state != 'init') 
     return; 

    jQuery.get('dynamic_ajax.txt', function(data) { 
     mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data); 
    }); 
}; 

function mycarousel_itemAddCallback(carousel, first, last, data) 
{ 
    // Simply add all items at once and set the size accordingly. 
    var items = data.split('|'); 

    for (i = 0; i < items.length; i++) { 
     carousel.add(i+1, mycarousel_getItemHTML(items[i])); 
    } 

    carousel.size(items.length); 
}; 

/** 
* Item html creation helper. 
*/ 
function mycarousel_getItemHTML(url) 
{ 
    return '<img src="' + url + '" width="75" height="75" alt="" />'; 
}; 

jQuery(document).ready(function() { 
    jQuery('#mycarousel').jcarousel({ 
     itemLoadCallback: mycarousel_itemLoadCallback 
    }); 
}); 

</script> 
</head> 
<body> 
<div id="wrap"> 
    <div id="mycarousel" class="jcarousel-skin-ie7"> 
    <ul> 
     <!-- The content will be dynamically loaded in here --> 
    </ul> 
    </div> 

</div> 

请解决我的问题.....

回答

0

怎么办你加载你的外部HTML? 因为我认为它无法在外部html上激发jQuery.ready事件。