ajax没有在外部div下加载

时间:2012-05-02 09:39:37

标签: ajax

我有外部html,我创建了jcorousal(图像通过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>

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

1 个答案:

答案 0 :(得分:0)

如何加载外部HTML? 因为,我认为它无法在外部html上激活jQuery.ready事件。