2012-05-02 100 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事件。