通过ajax加载的内联脚本

时间:2012-08-10 14:18:58

标签: jquery ajax inline product

我正在使用360产品spin jquery插件: Link to 360-javascriptviewer

这是通过html底部的以下内联脚本激活的,并且工作正常。

function test () {
    mloaderx = new loader(
    {
    tag:'product_image_x',
    frames:36,
    zoom:false
    });
}
test();

我遇到的问题是当这个内容通过ajax加载到另一个页面时。即使我将其包含在另一页上,内联脚本也无法完成。

我已经包含了下面的整个代码,但它唯一关注的部分是ajax调用。

// NOTES: This script will load content into a placeholder div with a nice scroll down effect.

jQuery(document).ready(function () {

    jQuery(".loadContent").click(function (event) {

        // show loading div
        showLoading();
        var clickedElement = jQuery(this);

        // stop initial jump to anchor.
        event.preventDefault();

        var contentURL = clickedElement.attr("href");

        jQuery.ajax({
            url: contentURL + "?" + new Date().toUTCString(),
            dataType: "html",
            success: function (strData) {
                populateContent(strData);
            },
            complete: function () {
                hideLoading();
                scrollToContent();

            }

        });
    });
});

function showLoading() {
    jQuery("#loading").fadeIn(100);
    jQuery("#loaded_content").slideUp(800);
}

function hideLoading() {
    jQuery("#loading").fadeOut(100);
    //jQuery(".to_top").show();
}

function populateContent(strData) {
    jQuery("#loaded_content").html(jQuery(strData).find("#loadarea").html());
    $('.media_main_content .article p:first').wrapFirstLetter();
}

function scrollToContent() {
    $("#subnav_content").toggle(800, function() {
        jQuery("#loaded_content").slideDown(800);
        jQuery('html,body').animate({ scrollTop: jQuery(".ca_nav_holder").offset().top}, 800, function() {
            jQuery("#toggle_subnav span").fadeTo(700, 0.1).fadeTo(700, 1);
        });
    });
}

有没有人可以提供任何建议?现在,我一直在用砖头撞击我的头两天,试图解决这个问题。

0 个答案:

没有答案